更好的jQuery Ajax错误信息 [英] Better jQuery Ajax error information
本文介绍了更好的jQuery Ajax错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当执行jQuery.ajax
调用并失败时,分配给error
选项的函数会提供非常少的错误信息,但是当我使用Chrome开发人员工具的网络"标签时,看到的响应中包含一个HTML文档对该错误进行了更为详尽和翔实的解释.
When do a jQuery.ajax
call, and it fails, the function assigned to the error
option provides very sparse error information, yet when I use Chrome developer tools, the network tab, I see the response includes an HTML document with a much more verbose and informative explanation of the error.
我可以从$.ajax
调用中获取此类错误信息吗?如果可以,怎么办?
Can I get this kind of error information back from the $.ajax
call, and if so, how?
推荐答案
您是否正在寻找类似的东西?
Are you looking for something like this?
$.ajax({ cache: false,
url: "/Admin/Contents/GetData",
}).fail(function (jqXHR, textStatus) {
document.body.innerHTML = jqXHR.responseText;
});
https://plnkr.co/edit/Aj7Tgxxno9fCcYBlwKuJ?p=preview
这篇关于更好的jQuery Ajax错误信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文