jquery ajax jsonp : this page is accessing information that is not under its control

标签 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?跨域问题的最佳替代方案是什么?

最佳答案

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

阅读此问题的答案:

jquery $.ajax jsonp

关于jquery ajax jsonp : this page is accessing information that is not under its control,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12863451/

相关文章:

jquery - 使用 Web Inspector 检查 AJAX HTTP 请求

jquery - 如何在 AJAX 中获取响应头

javascript - 为什么 Mapbox 方向不支持 JSONP ?怎么解决呢?

javascript - AJAX调用后如何正确获取JSON?

json - 通过 JSONP 在 CDN 上的静态 JSON 文件

javascript - 如何在 Choreographer JS 中使用转换 CSS 属性?

javascript - 鼠标悬停时 html 元素的 CSS 选择器

javascript - 获取 json 数据时 jquery 有问题

javascript - 获取div高度的最快方法

jquery - 如何结合每个然后