0

当我使用 Skyscanner Api 创建会话时,我可以得到 201 响应,这意味着会话已创建。但是有一个例外,结束我的脚本,“请求的资源上没有'Access-Control-Allow-Origin'标头。因此不允许访问Origin'null'”。这是我的代码。

    var apikey = "prtl6749387986743898559646983194";
    var url = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0/?   apikey=" + apikey;
    $.ajax({
        type:"POST",
        url:url,
        dataType:"json",
        crossDomain: true,
        Accept:"application/json",
        data:{
            country:"UK",
            currency:"GBP",
            locale:"en-GB",
            locationSchema:"iata",
            apikey:"prtl6749387986743898559646983194",
            grouppricing:"on",
            originplace:"EDI",
            destinationplace:"LHR",
            outbounddate:"2016-05-29",
            inbounddate:"2016-06-05",
            adults:1,
            children:0,
            infants:0,
            cabinclass:"Economy" 
        },
        contentType:"application/x-www-form-urlencoded",
        success:function(){
            console.log("success");
        }
    });
4

1 回答 1

-1

应该在服务器端启用跨域。如果没有完成。您的代码将无法正常工作。

于 2016-05-22T14:25:46.030 回答