我有以下代碼jquery ajax返回true但不顯示正確的消息?
$(document).ready(function(){
// class exists
if($('.delete').length) {
// add click handler
$('.delete').click(function(){
// ask for confirmation
var result = confirm('Are you sure you want to delete this?');
var vid = $(this).attr('id');
var row = $(this).parents('tr');
// do ajax request
if(result) {
$.ajax({
type:"POST",
url:"delete_joke.php",
data:{id:vid,garbage:'FG9g543hfh'},
dataType: "json",
success:function(response){
// hide table row on success
if(response == "true") {
row.fadeOut();
$('#errors').show();
$('#errors').html('<div class="message green"> Successfully deleted!<img src="http://puppetweb.ca/play/views/admin/gfx/icon-close.gif" alt="Close this item" /> </div>').show();
}else{
$('#errors').show();
$('#errors').html('<div class="message red"> Error deleting. <img src="http://puppetweb.ca/play/views/admin/gfx/icon-close.gif" alt="Close this item" /> </div>').show();
}
}
});
}
return false;
});
}
});
和它的作品,直到我想要展現成功的一部分,我有PHP腳本打印成功「真」與「假」的錯誤,如果我做警報(響應)它顯示單詞真實。但它顯示錯誤成功刪除和錯誤刪除錯誤?
任何幫助?
請發帖也php代碼。也許問題在那裏。 – 2011-06-09 03:00:51