Ajax error reporting cross domain, AJAX cross domain access error 501 solution

Problem: Ajax cross domain access error 501

Running the following code will report error 501


type: “POST”,

url: ” “,

contentType:’application/json; charset=utf-8′,

data: JSON.stringify(ajaxPostData),


success: function(data){

//On ajax success do this


if (data[“status”] == “ok”){

alert(“Settings is Ok. The Machine is rebooting.”);



error: function(xhr, ajaxOptions, thrownError) {

//On error do this


if (xhr.status == 200) {



else {







Remove contenttype: ‘application/JSON; charset=utf-8’


1. When cross domain, the browser will be triggered to send a request with the method options first, except that the contenttype is application/x-www-form-urlencoded, multipart/form data or text/plain.

2 for example, your original request is the post method. If the allow attribute in the header of the result returned by the first request does not have the post method,

3 then the second request will not be sent. At this time, the browser console will report an error and tell you that the post method is not supported by the server.

The above is the whole content of this article. I hope it will help you in your study. I also hope you can support us to find the tutorial network.

Read More: