0

When I used Skyscanner Api,creating the Session,I can get 201 response ,which means that session created. But there is a exception,ending my script, "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access". Here is my code.

    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");
        }
    });
JunTU
  • 1
  • You're trying to access a resource that does not expect to be accessed from pages served from other domains. It's basic browser security. – Pointy May 22 '16 at 14:25
  • 1
    The skyscanner API does not look like its designed to be used from browsers. Your probably going to have to have a server side proxy. – user1937198 May 22 '16 at 14:28
  • I see . What you said inspires me . I wanted to figure out how to make it work in javascript all the time but it makes no sense..According to your comment ,it seems that I can use this api in java or etc . I just want to use the api to get some information and processing,so it doesn't has to be js. – JunTU May 22 '16 at 14:43

1 Answers1

-1

Cross-domain should be enabled on the server side. If it is not done. Your code won't work.

Oss
  • 4,232
  • 2
  • 20
  • 35