jQuery的Ajax错误功能 [英] jQuery ajax error function
本文介绍了jQuery的Ajax错误功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Ajax调用将数据传递到一个页面,然后返回一个值。
I have an ajax call passing data to a page which then returns a value.
我已经检索到的页面中调用成功,但我有codeD,以便它提出了在ASP错误。我如何检索错误从jQuery?
I have retrieved the successful call from the page but i have coded it so that it raises an error in the asp. How do i retrieve that error from the jquery?
例如:
cache: false,
url: "addInterview_Code.asp",
type: "POST",
datatype: "text",
data: strData,
success: function (html) {
alert('successful : ' + html);
$("#result").html("Successful");
},
error: function (error) {
**alert('error; ' + eval(error));**
}
它的错误位,我不明白。在函数的参数是什么,你在里面放。好让你能够然后使用我的错误信息在ASP页提出
推荐答案
试试这个:
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
如果你想告诉你的前端大约一个验证错误,试图返回JSON:
If You want to inform Your frontend about an validation error, try to return json:
dataType: 'json',
success: function(data, textStatus, jqXHR) {
console.log(data.error);
}
您的ASP脚本schould返回:
Your asp script schould return:
{"error": true}
这篇关于jQuery的Ajax错误功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文