我在 json 中得到响应(可以在 firebug 中检查),但这不会解析 json 响应并且没有显示结果。我做错了什么?我在文档http://docs.jquery.com/Plugins/Autocomplete上找不到任何东西
这是我的 JSON 响应
({"Contacts":[{"Phone":"","Email":"","Labels":"","Mobile":"12345678","Firstname":"john"}]});
这是我的 jQuery:
$("#destinations").autocomplete({
source: function (request, response) {
$.getJSON("http://localhost/contactApi.do?callback=?",
{ 'contactMobile': request.term, maxRows: 12, style: "full" },
function(data) {
if(data.Contacts){
var x = $.map(data.Contacts, function(v, i){
console.log(v)
return {
label: v.Mobile + ' - ' + v.Firstname,
v: v.Firstname
}
});
response(x);
}
}
);
}
})