I’m new here, and I’m having a problem with ajax autocomplete, I get this error with Firebug (in Firefox):
g.nodeName is undefined
c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];
jquery….min.js (linha 977)
and in 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)
Can someone help me with that, I’m using jQuery 1.7.2-min complete, and I followed this tutorial http://www.jensbits.com/2011/08/24/using-jquery-autocomplete-when-remote-source-json-does-not-contain-label-or-value-fields/
My json source returns code above:
[{"id":"1","campo":"[1] Empresa Tal"},{"id":"2","campo":"[2] Outra Empresa Tal"},{"id":"3","campo":"[3] Mais Outra Empresa"}]
My javascript function:
$('#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);
}
});
Hello Sir i think you are getting this error because you are using $(this).val();
Replace that code with you id $(your element id).val().