由网友(纯真的眼眸)分享简介:JS code:$.ajax({type: 'POST',url: 'http://localhost/MyServiceDir/Service.asmx/Foo',contentType: 'application/json; charset=utf-8',data: jsonData,success: func...
JS code:
$.ajax({
type: 'POST',
url: 'http://localhost/MyServiceDir/Service.asmx/Foo',
contentType: 'application/json; charset=utf-8',
data: jsonData,
success: function (msg) {
alert("good");
},
error: function (xhr, status) {
switch (status) {
case 404:
alert('File not found');
break;
case 500:
alert('Server error');
break;
case 0:
alert('Request aborted');
break;
default:
alert('Unknown error ' + status);
}
}
});
我得到未知错误错误。我如何到达这条底线?我想知道是什么错误实际上是。谢谢!
I get "unknown error error". How do I get to the bottom of this? I would like to know what the error actually is. Thanks!
推荐答案
状态参数只包括为什么会失败 - 超时,错误,等等......为了获得状态code,你需要检查响应对象: xhr.status
The "status" parameter only includes why it failed -- timeout, error, etc... To get the status code you need to check the response object: xhr.status
请参阅 http://www.w3.org/TR/XMLHttprequest /#响应了解详细信息。
如果您收到500内部服务器错误的是的所有,你会从阿贾克斯得到。你必须检查你的应用程序或服务器日志。这可能是一个语法错误或或库错误或别的东西沿着这些线路。
If you are getting "500 Internal Server Error" that is all you are going to get from ajax. You will have to check your application or server logs. This could be a syntax error or or library error or something else along those lines.
相关推荐
最新文章