Uncaught SyntaxError: Unexpected token : Can't resolve
Uncaught SyntaxError: Unexpected token : Can't resolve
我一直在控制台中收到我似乎无法解决的语法错误。当我将 link 复制并粘贴到浏览器时,它工作正常。有人可以帮忙吗?我查看了其他线程并重新输入 link 以防有隐藏字符,但这并没有解决问题。
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"
我一直在控制台中收到我似乎无法解决的语法错误。当我将 link 复制并粘贴到浏览器时,它工作正常。有人可以帮忙吗?我查看了其他线程并重新输入 link 以防有隐藏字符,但这并没有解决问题。
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"