我試圖登錄從JSON調用返回的數據,並console.log(jsonData)
似乎並不奏效。
代碼
$(document).ready(function() {
$("#users li a:first-child").click(function() {
var id = this.href.replace(/.*=/, "");
this.id = "delete_link_" + id;
if(confirm("Are you sure you want to delete this user?"))
{
$.getJSON("delete.php?ajax=true&id=" + id, function(data) {
console.log(data.success);
});
}
return false;
});
});
在成功通過delete.php
{"id": $id, "success": 1}
返回。
{"id": $id, "success": 0, "error": "Could not delete user."}
失敗。
那麼,控制檯顯示什麼'console.log(data.success);'? 「似乎沒有工作」不是一個有用的錯誤描述。 –
什麼是「delete.php」_really_返回(ID替換)? –
假設$ id是數字,你應該工作得很好。試試'console.log(arguments)'來獲取更多信息。 –