jquery ajax jsonp:此页面正在访问不受其控制的信息



我正在尝试解决Jquery跨域问题。

使用以下代码,我在IE中得到"此页面正在访问不受其控制的信息.."

$.ajax({
    type: "Post",
    url: "http://Webbie/WS.asmx/TrackLink",
    data: params,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: true,
    cache: true,
    success: function (msg) {
       alert('success');
    },
    error: function (request, status, error) {
       alert('error')
    }
});

收到IE消息,一旦我批准,我就会到达"成功"警报。

我尝试用以下代码将 json 替换为 jsonp(只是将数据类型从"json"更改为"jsonp")

$.ajax({
    type: "Post",
    url: "http://Webbie/WS.asmx/TrackLink",
    data: params,
    contentType: "application/json; charset=utf-8",
    dataType: "jsonp", // just added the p
    async: true,
    cache: true,
    success: function (msg) {
       alert('success');
    },
    error: function (request, status, error) {
       alert('error')
    }
});

使用上面的jsonp代码,我收到错误500。

为什么我会收到错误 500? 跨域问题的最佳选择是什么?

通过简单的 JSON 进行 POST 是不可能的。

阅读此问题的答案:

jquery $.ajax jsonp

最新更新