开发者

jQuery ajax post returns with 501 error code

开发者 https://www.devze.com 2023-01-26 18:55 出处:网络
We are using jQuery(1.2.3) ajax post and we are getting 12031/501 error message sporadically. What could be the reason of this error?

We are using jQuery(1.2.3) ajax post and we are getting 12031/501 error message sporadically.

What could be the reason of this error?

Sample code


jQuery.post('${pageContext.request.contextPath}/sample/someAction.do', jQuery("#form_name").serialize(), function(status){
      //Some other code for checking the status......
}

Form has two textarea(one disabled, one enabled) and a check box. And a submit button.

And there is one ajax error handling function which is for handling 12031/501 kind of error msg. Which sometimes shows a alert box saying that error happen in ajax post.


$("#form_name").ajaxError(function(event, xhr, settings, exception) {
 var errorMessage = "Error in ajax post -";
 errorMessage += "\n\t url: " + settings.url;
 errorMessage += "\n\t exception: " + exception + ((exception) ? " - " + exception.description : "");
 开发者_开发技巧errorMessage += "\n\t readyState: " + xhr.readyState;
 errorMessage += "\n\t status: " + xhr.status;
 errorMessage += "\n\t statusText: " + xhr.statusText;
 errorMessage += "\n\t responseText: " + xhr.responseText;
 errorMessage += "\n\t";
 alert('Error occured in ajax post..........'+errorMessage);
 }); 

This alert box will display only when there is error on ajax post and the error code is 12031(The connection with the server was reset.) or 501/12152.

Now there is one more error code we are able to see is 12152(The server returned an invalid or unrecognized response.).

Is this a jQuery(1.2) issue or something else in environment or is it IE7?

If we resubmit the request then it is working fine. For now we are telling user to resubmit the request so that data can be saved.

Now this is not a viable solution. And this problem occurs sporadically.

Any insight on those error codes would really be appreciated.

Thanks


Ajax does a request to the server, the server returns the 501. Therefore, look at why the server returns 501.

And you should make sure the XMLHttpRequest made was proper - right url, arguments, etc obviously.


The 501 error is because the server you are using (presumably something like simpleHTTPServer) doesn't support POST requests.

To resolve that error you need to use a server that supports POST requests like apache

0

精彩评论

暂无评论...
验证码 换一张
取 消