Home  >  Article  >  Backend Development  >  ajax cross-domain request problem

ajax cross-domain request problem

WBOY
WBOYOriginal
2016-09-22 08:42:151216browse

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?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn