我能够检测到成功的响应,但无法检测到错误。我的代码:
$.ajax({
url: url,
dataType: 'jsonp',
success: function(data){
$.each(data, function(a, b) {
if(b=="Processing post"){
$("#post_response").html('Your comment will be added soon...');
}
else if(b=="In moderation"){
$("#post_response").html('Your comment has been placed in moderation...');
}
})
},
error: function(xhr, testStatus, error) {
alert("error");
}
});
这些是我收到的回复。我可以检测到前 2 个响应,但我什至无法提醒最后一个响应的“错误”。
jQuery191004289518775843171_1361906819321({"Message":"Processing post","Code":202})
jQuery191006158838421090984_1361907415719({"Message":"In moderation","Code":202})
jQuery191006158838421090984_1361907415719({"Message":"Not logged in","Code":403})
你能看出我哪里错了吗?