Home > Article > Backend Development > ajax cross-domain request problem
The php side has header("Access-Control-Allow-Origin:*");
ajax request
<code> $.ajax( { type : "post", url : url, async : false, dataType: 'json', data : {asdsa:1}, success : function (obj) { //业务代码 }, error : function (obj) { alert('未找到文件'); } } );</code>
If data is shorted, for example {}, an error will be reported. The CORS header is missing 'Access-Control-Allow-Origin'
Data Just write a parameter such as {dasdsa:1} and it's normal. What's going on?
This problem did not occur when cross-domain access was not bound to a domain name on the test machine, but now it does not work if the domain name is bound online
ps. There is a difference between testing and going online. Apache is used for testing the backend, and nginx is used for the backend going online. Does this have anything to do with it?