我是新来的,而我在与AJAX自动完成的问题,我得到这个错误使用Firebug(在Firefox):自动完成AJAX g.nodename未定义
g.nodeName is undefined
c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];
jquery....min.js (linha 977)
,并在Chrome:
Uncaught TypeError: Cannot call method 'toLowerCase' of undefined jquery-1.7.2.min.js:977
f.fn.extend.val jquery-1.7.2.min.js:977
$.autocomplete.source novo:77
a.widget._search jquery-ui-1.8.18.custom.min.js:127
a.widget.search jquery-ui-1.8.18.custom.min.js:127
(anonymous function)
有人可以帮我的是,我使用jQuery 1.7.2分钟完成,我跟着这个教程上面http://www.jensbits.com/2011/08/24/using-jquery-autocomplete-when-remote-source-json-does-not-contain-label-or-value-fields/
的json源代码的回报:
[{"id":"1","campo":"[1] Empresa Tal"},{"id":"2","campo":"[2] Outra Empresa Tal"},{"id":"3","campo":"[3] Mais Outra Empresa"}]
我的JavaScript函数:
$('#accadempresa').autocomplete({
source: function(request, response) {
$.ajax({
url: '/ajax.php?action=available&orm=cadempresa&campo=razsoc&valor=' + $(this).val(),
dataType: "json",
data: {term: request.term},
success: function(data) {
response($.map(data, function(item) {
return {
id: item.id,
campo: item.campo
};
}));
}
});
},
minLength: 2,
select: function(event, ui) {
alert('ae');
//$('#state_id').val(ui.item.id);
//$('#abbrev').val(ui.item.abbrev);
}
});
尝试给ajax调用添加“async:false”。 –
不能正常工作,请参阅我的页面:http://pastebin.com/wj3gyA2n – douglasjam