[英]How do I debug Jquery Success function
I am using Javascript to get records from the database, everything works the way i want but i cannot show alerts in success handler. 我正在使用Javascript从数据库获取记录,一切都按我想要的方式工作,但我无法在成功处理程序中显示警报。 When i place a break point to sucess:function(data) it gets hit but this line is not being hit
$("#Alert").html(data).show()....
Another unusually thing i have noticed is that some time $("#Alert").html(data).show()..
gets hit. 当我在成功处放置一个断点:function(data)时,它会命中,但未命中此行
$("#Alert").html(data).show()....
我注意到的另一件不寻常的事是一段时间$("#Alert").html(data).show()..
被点击。 Is there any way i can debug this? 有什么办法可以调试吗?
function MethodNAme() {
ajReq.abort();
ajReq = $.ajax({
type: "POST",
url: "Services/",
data: ,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
getSomething();
$("#Alert").html(data).show().delay(5000).fadeOut();
alert("working");
}
}
your syntax is not correct, you are placing a function getSomething()
in middle of $.ajax(), 您的语法不正确,您要在$ .ajax()的中间放置一个函数
getSomething()
(),
function MethodNAme() {
ajReq.abort();
ajReq = $.ajax({
type: "POST",
url: "Services/",
data: {},
contentType: "application/json; charset=utf-8",
dataType: "json",
// getSomething(); <-- remove this
success: function (data) {
$("#Alert").html(data).show().delay(5000).fadeOut();
alert("working");
}
});
}
You can use console.log()
to print data in browser console. 您可以使用
console.log()
在浏览器控制台中打印数据。 You can access console window by pressing F12
key and then go to console tab. 您可以通过按
F12
键访问控制台窗口,然后转到控制台选项卡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.