我在这个插件上花了两天时间,没有成功 - 仅适用于本地数据阵列:( 我有一个代码(django / python)生成json字符串(有效 - 在http://jsonlint.com/上测试),如下所示:
[{"id": 7626, "value": "Jaros\u0142aw", "label": "Adrianowicz"}, {"id": 2702, "value": "Bo\u017cena", "label": "Baranowicz"}, {"id": 2542, "value": "Tomasz", "label": "Baranowicz"}]
我的jquery代码是:
$('#query').autocomplete({
source: "/aut/", //this generate json and working
minLength: 2
});
我检查ajax示例 - geonames - 这个工作正常。有什么帮助吗?
答案 0 :(得分:0)
您可以在自动填充中使用任何.ajax选项。试试这个
$('#query').autocomplete({
source: "/aut/", //this generate json and working
dataType: "json",
minLength: 2
});
答案 1 :(得分:0)
对于source的值,您可以使用回调而不是页面的url,如下例所示:
http://jqueryui.com/demos/autocomplete/#remote-with-cache
使用回调允许您为.ajax编写自己的成功和错误处理。您可能希望使用.ajax并检查错误。