我有我自己的示例在本地運行,但我無法得到它與jsonp源數據掛鉤。它與json數據一起工作正常。jQuery UI自動完成與Jsonp源代碼的幫助?
我看了樣品這裏http://jqueryui.com/demos/autocomplete/remote-jsonp.html
如果我理解正確的事情JSONP返回字符串,它是包括了一個js函數的調用。在上面的示例中,返回時似乎沒有調用函數。這是怎麼回事?
在我的示例中,它返回的數據看起來像下面的樣子,並且返回它想要調用js函數myfunc。
myfunc([{"results":[
{"id":"0","name":"Leonor"},
{"id":"1","name":"Terry"},
{"id":"2","name":"James"},
{"id":"3","name":"Benjamin"},
{"id":"4","name":"Regina"},
{"id":"5","name":"Debra"}
],"total":"5"}])
上面的示例返回的數據如下所示。但是請注意,它並不試圖調用函數jQuery15107172246546687473_1305657637754
爲什麼我的代碼想要調用myfunc,但是jquery ui示例沒有調用jQuery15107172246546687473_1305657637754函數?
jQuery15107172246546687473_1305657637754({"totalResultsCount":1519,"geonames":[{"alternateNames":[{"name":"Yar","lang":"en"},{"name":"Jar","lang":"no"},{"name":"ЯР","lang":"ru"}],"countryName":"Russia","adminCode1":"80","fclName":"city, village,...","score":28.82040023803711,"countryCode":"RU","lng":52.1052778,"adminName2"
...
,"lat":55.019887,"adminName1":"Novosibirsk","population":0}]});
是完整的,我包括jQuery的用戶界面的示例代碼視圖源:http://jqueryui.com/demos/autocomplete/remote-jsonp.html