Nahla Ibrahim
Nahla Ibrahim

Reputation: 13

Uncaught SyntaxError: Unexpected token : Can't resolve

I keep on getting a syntax error in the console that I can't seem to resolve. When i copy and paste the link to the browser, it works just fine. Could someone help? I looked at the other threads and retyped the link in case there was a hidden character, but that didn't solve the issue.

function searchHotwire(city){

    console.log(city);
    var hotwireURL1 = "http://api.hotwire.com/v1/search/hotel?apikey={keyRemoved}&format=json&dest=";
    var hotwireSearchURL1 = hotwireURL1 + city;
    var hotwireURL2 = "&rooms=1&adults=1&children=0&startdate=10/20/2015&enddate=10/21/2015";
    var hotwireSearchURL2 = hotwireSearchURL1 + hotwireURL2;

    $.ajax({
        url: hotwireSearchURL2,
        type: "GET",
        dataType: "jsonp",
        error: function(data){
            console.log("We got a problem");
            console.log(hotwireSearchURL2);
            console.log(data);
        },
        success: function(data){
            console.log(hotwireSearchURL2);
            console.log(data);

         }
    });

}

$(document).ready( function(){

    $("#theButton").click( function(){

        console.log("you clicked");
        var theCityValue = $("#destination").val();
        console.log(theCityValue);

        searchHotwire(theCityValue);


    });

});

Upvotes: 1

Views: 118

Answers (1)

epascarello
epascarello

Reputation: 207537

So you tell the jQuery Ajax call it is "JSONP" and you are requesting "format=json" from the api.

Upvotes: 2

Related Questions