【问题标题】:cross domain request with ajaxajax跨域请求
【发布时间】:2014-03-25 07:23:11
【问题描述】:

我正在尝试使用 ajax 请求从我的本地域重定向到 Paypal 结帐域。我也允许跨域为 true。但我收到了错误

  No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin      'http://localhost' is therefore not allowed access. 

我的代码是:

$.ajax({
            type: 'GET',
            url: url,
            processData: false,
            crossDomain: true,
            contentType: "application/json",
            jsonp: false,
            success: function() {
                alert("Success");
            },
            error: function() {
                alert("failure");
            }
    });

【问题讨论】:

    标签: ajax paypal cors


    【解决方案1】:

    为了允许 CORS 请求,SERVER 端需要在响应中填充 Access-Control-Allow-Origin 标头。我认为 Paypal 服务器不这样做,所以这就是您收到错误的原因。

    欲了解更多信息,请参阅此链接:https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS

    【讨论】:

      猜你喜欢
      • 2013-03-06
      • 1970-01-01
      • 2012-04-15
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-04
      相关资源
      最近更新 更多