对于我的生活,我似乎无法用我的javascript找到问题。 Firebug正在吐出以下错误:
missing ) after argument list
[Break on this error] $.getJSON('http://local.yahooapis.co... results +'&output=json&callback=?',\n
这是我的代码:
function getLocationJSON(fooBar) {
var appid = 'RvkxtGN.OtlDnsdkjsdP_DsOD3xXzFlW6LL6u3y3wTcW4zWZVgQL9O14X78ZoBY9c-';
var results = 5;
var query = 'pizza';
var lat;
var lon;
$('#whereLocationSelector').click(function() {
function setDisplay(text) {
$('#whereLocationSelector').empty().append(text);
}
jQT.updateLocation(function(coords){
if (coords) {
setDisplay('Location Acquired!');
lat = coords.latitude;
lon = coords.longitude;
} else {
setDisplay('Device not capable of geo-location.');
}
});
}
$.getJSON('http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=' + appid + '&query=' + query + '&latitude=' + lat +'&longitude=' + lon + '&results=' + results + '&output=json&callback=?',
function(funWorld) {
console.log(funWorld);
});
}
对于将来自行调试此方法的任何建议,我们将不胜感激。
答案 0 :(得分:2)
您需要}
之前使用});
$.getJSON('http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=' + appid + '&query=' + query + '&latitude=' + lat +'&longitude=' + lon + '&results=' + results + '&output=json&callback=?', line
即 替换
}
$.getJSON('http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=' + appid + '&query=' + query + '&latitude=' + lat +'&longitude=' + lon + '&results=' + results + '&output=json&callback=?',
function(funWorld) {
console.log(funWorld);
});
}
用
});
$.getJSON('http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=' + appid + '&query=' + query + '&latitude=' + lat +'&longitude=' + lon + '&results=' + results + '&output=json&callback=?',
function(funWorld) {
console.log(funWorld);
});
}
答案 1 :(得分:1)
你应该把你的功能放在外面。对于
$('#whereLocationSelector').click(function() {
结束标记不正确。我已经解决了以下问题:
function getLocationJSON(fooBar) {
var appid = 'RvkxtGN.OtlDnsdkjsdP_DsOD3xXzFlW6LL6u3y3wTcW4zWZVgQL9O14X78ZoBY9c-';
var results = 5;
var query = 'pizza';
var lat;
var lon;
$('#whereLocationSelector').click(function() {
function setDisplay(text) {
$('#whereLocationSelector').empty().append(text);
}
jQT.updateLocation(function(coords){
if (coords) {
setDisplay('Location Acquired!');
lat = coords.latitude;
lon = coords.longitude;
} else {
setDisplay('Device not capable of geo-location.');
}
});
});
$.getJSON('http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=' + appid + '&query=' + query + '&latitude=' + lat +'&longitude=' + lon + '&results=' + results + '&output=json&callback=?',
function(funWorld) {
console.log(funWorld);
});
}