简体   繁体   中英

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


    });

});

因此,您告诉jQuery Ajax调用它是“ JSONP”,并且您正在从api请求“ format = json”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM