使用ajax跨域请求

时间:2014-03-25 07:23:12

标签: ajax paypal cors

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

  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");
            }
    });

1 个答案:

答案 0 :(得分:1)

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

有关详情,请参阅以下链接:https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS

相关问题