不能让这个jQuery AJAX + JSONP工作.“没有& # 39;Access-Control-Allow-Or


Cannot get this jQuery AJAX + JSONP to work. "No 'Access-Control-Allow-Origin' header is present"

我希望有人能帮帮我。

每次我尝试运行下面的代码,我得到以下错误:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 

这是客户端JS代码:

function checkIP() {
    jQuery.ajax({
        async: false,
        url: "http://www.acme.ie/test/checkip.php",
        type: "get",
        dataType: 'jsonp',
        jsonp: 'callback',
        jsonpCallback: 'jsoncallback',
        success: function(data) {
                alert("success");
        },
        beforeSend: function(XMLHttpRequest) {},
        error: function(XMLHttpRequest, textStatus, errorThrown) {}
    })
}
jQuery.noConflict();
checkIP();

服务器响应代码(http://www.acme.ie/test/checkip.php):

)
header("Content-Type: application/json");
echo "jsonCallback({'1' : '1'})";

我看了很多例子,我似乎做的每件事都是正确的。

你知道怎么回事吗?

谢谢

尝试添加:

headers: {'Access-Control-Allow-Origin': '*'},