Jquery ui自动完成+来自php的json数据
我正在尝试使用jquery ui autocomplete和json自动完成一个字段,数据来自php文件。。。但是没有任何结果 以下是我的jquery代码:Jquery ui自动完成+来自php的json数据,jquery,jquery-ui,Jquery,Jquery Ui,我正在尝试使用jquery ui autocomplete和json自动完成一个字段,数据来自php文件。。。但是没有任何结果 以下是我的jquery代码: $('#rech_abo').keyup(function(e) { e.preventDefault(); $( ".find_group_ac" ).autocomplete({ minLength: 3, source: function(request
$('#rech_abo').keyup(function(e) {
e.preventDefault();
$( ".find_group_ac" ).autocomplete({
minLength: 3,
source: function(request, response) {
$.ajax({
url: "/chercheabo",
data: {achercher : $("#rech_abo").val()},
dataType: "json",
type: "POST",
success: function(data) {
response($.map(data, function(obj) {
return {
label: obj.pseuDO,
value: obj.userID,
// description: obj.description
// id: obj.userID // don't really need this unless you're using it elsewhere.
};
}));
}
});
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
// Inside of _renderItem you can use any property that exists on each item that we built
// with $.map above */
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "<br>" + item.description + "</a>")
.appendTo(ul);
};
});
和我的html:
<div class=\"abo_parnom\"><input class=\"input_text_compte\" type=\"text\" placeholder=\"Tappez un nom\" id=\"rech_abo\"> <input type=\"button\" id=\"rech_abo_valider\" class=\"bouton_suppr\" value=\"Ok\"></div>
你知道这里少了什么吗?
谢谢Autocomplete使用术语进行搜索。尝试用$\u POST['term']替换$\u POST[achercher]。您是否以独立的方式测试过您的查询?控制台中的AJAX调用是否有JSON响应?有什么错误吗?为什么您的URL没有文件扩展名?如果我删除数据自动完成。\u renderItem=function ul,item,我在控制台中不会收到任何消息。如果我允许,我有未捕获的TypeError:无法将属性“\u renderItem”设置为null我没有文件扩展名,因为它是url重写
<div class=\"abo_parnom\"><input class=\"input_text_compte\" type=\"text\" placeholder=\"Tappez un nom\" id=\"rech_abo\"> <input type=\"button\" id=\"rech_abo_valider\" class=\"bouton_suppr\" value=\"Ok\"></div>