Hey guys,
I am using jQuery's auto-complete plugin for a simple search form. I am having trouble converting my JSON object data into an array for usage with auto-complete.
My code:
var listOfOrderedByNames = getAutocompleteData();
$('#OrderedBy').autocomplete(listOfOrderedByNames);
function getAutocompleteData() {
var output;
$.getJSON('AJAX/GetOrderedByNames', function(data) {
$.each(data, function(index, optionData) {
output += optionData + "|";
});
});
return output;
}
My JSON data that is returned looks like this:
["Jimmy","John", "Etc",null]
For some reason it looks like what I'm getting back from that getAutocompleteData
function is an empty string and I don't know what is wrong.
Please help!