简体   繁体   English

未捕获的SyntaxError:意外令牌:无法解析

[英]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”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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