我有这样的代码:简单的jQuery/AJAX错误
var custID = 1;
$.ajax({
url: 'php/viewCustomer.php',
type: 'GET',
data: '{custID: ' + custID + '}',
dataType: 'json',
cache: false,
beforeSend: function() {
$('#display').append('<div id="loader"> Lodaing ... </div>');
},
complete: function() {
$('#loader').remove();
},
success: function (data) {
//do something
},
error: function() {
alert('could not process');
}
});
存在错误和警告该错误消息could not process
,所以我试图调试它是这样的:
var custID = 1;
$.ajax({
url: 'php/viewCustomer.php',
type: 'GET',
data: '{custID: ' + custID + '}',
dataType: 'json',
cache: false,
beforeSend: function() {
$('#display').append('<div id="loader"> Lodaing ... </div>');
},
complete: function() {
$('#loader').remove();
},
success: function (data) {
//do something
},
error: function (jqXHR) {
alert('Error: ' + jqXHR.status + jqXHR.statusText);
}
});
,其输出:
200 OK
所以,如果它是好的,为什么地球上它执行错误:函数。困惑,请帮助。
我相信你可以编辑它,如果它太困扰你了 – 2013-03-06 17:35:29
我的观点是编辑,OP会看到你正在编辑并理解他在钓鱼时很糟糕。 – 2013-03-06 18:00:13