I am working on getting an autocomplete from a remote data source. It is return JSON but it doesn’t populate the autocomplete box.
$( "#patientName").autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://localhost:8080/cs/accountTypeAhead",
dataType: "json",
type: 'POST',
data: { "patientName": $("#patientName").val(),
"requestID": (new Date()).getTime()},
success: function( data ) {
var searchInfo = new Array();
for(var key in data)
{
if(typeof data[key] === "object") {
for(var i = 0; i < data[key].length; i++)
{
searchInfo.push(data[key]);
}//end for loop
}//end if
else if(key == "requestID")
{
if (data.requestID < $("#requestID").val() )
{ return false;}
else
{
$("#requestID").val(data.requestID);
}
}//end if/else
}//end for loop
return searchInfo;
}
});
},
minLength: 1,
});
My output from console is what I was expecting. I think it has something to due with returning the array.
Try changing
by