我正在使用 jQuery、jQuery-UI 自动完成以及此链接作为源
https://www.google.com/finance/match?matchtype=matchall&callback=callback&q=aa&_=1379423108762
这是我的代码:
$("#searchinput").autocomplete({
source: function (request, response) {
var q=request.term;
$.ajax({
type: "GET",
// url: "http://d.yimg.com/autoc.finance.yahoo.com/autoc", for http use only
url: "https://www.google.com/finance/match?matchtype=matchall",
data: {q: q},
dataType: "jsonp",
contentType: 'application/json; charset=utf-8',
jsonp : "callback",
jsonpCallback: "callback",
});
// call back function
callback = function (data) {
var suggestions = [];
//alert(JSON.stringify(data.matches));
$.each(data.matches, function(i, val) {
suggestions.push("Name:"+ val.n+" #Symbol:"+val.t+" #Exchange:"+val.e);
});
response(suggestions);
}
},
minLength: 1,
select: function (event, ui) {
$("#searchinput").val(ui.item.value.split("#")[0]);
},
});
我收到以下错误
Uncaught SyntaxError: Unexpected token :
在这里你可以看到错误图片:http: //i.stack.imgur.com/NYMPG.jpg