如何调试一个jQuery Ajax请求? [英] How do I debug a jQuery Ajax request?
本文介绍了如何调试一个jQuery Ajax请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的code是:
var test = "it isn't working";
var response = $.ajax({
type: 'GET',
url: 'jquerydemo.php', //This is in the same site as the page calling this request, so it's not a same-domain error.
success: function(){
test = "it's working";
},
error: function(){
alert("Error detected");
}
}).responseText;
alert(test);
我测试了状态code和它出来到200和误差函数永远不会熄灭,但同样没有成功的功能。就像我在我的评论说,这不是一个同源策略错误。它只是停留说:它不工作。这是怎么回事吗?
I tested the status code and it came out to a 200 and the error function never goes off, but neither does the success function. Like I said in my comment, it isn't a same-origin policy error. It just stays saying "it isn't working". What's going on here?
推荐答案
试试这个:
error: function(jqXHR, textStatus, errorThrown) {
console.log(JSON.stringify(jqXHR));
console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
}
这篇关于如何调试一个jQuery Ajax请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文