jQuery Autocomplete fetch and parse data source with custom function, except not
Posted
by Ben Dauphinee
on Stack Overflow
See other posts from Stack Overflow
or by Ben Dauphinee
Published on 2010-05-21T15:21:21Z
Indexed on
2010/05/21
15:30 UTC
Read the original article
Hit count: 291
So, I am working with the jQuery Autocomplete function, and am trying to write a custom data parser. Not sure what I am doing incorrectly, but it throws an error on trying to call the autocompleteSourceParse function, saying that req is not set.
setURL("ajax/clients/ac");
function autocompleteSourceParse(req, add){
var suggestions = [];
$.getJSON(getURL()+"/"+req, function(data){
$.each(data, function(i, val){
suggestions.push(val.name);
});
add(suggestions);
});
return(suggestions);
}
$("#company").autocomplete({
source: autocompleteSourceParse(req, add),
minLength: 2
});
© Stack Overflow or respective owner