I want to make autocomlplete for remote data source, I get all data from database and return it as jSon, using console I see that all data has been returned, but the autocomplete doesn’t work, also the alert in my code doesn’t work, here’s my code
$("#cellPhoneNo").autocomplete({
source: function(request, response) {
var param = {
"action": "getCellPhoneNos"
};
$.getJSON("controllers/Customer.controller.php", param, function(result) {
alert('here'); //doesn't alert
// cellPhoneSource=result;
});
},
select: function(event, ui) {
alert('response');
}
});
EDIT
I try to get the source using GET , I make like this
source:function(request,response){
var param= {"action":"getCellPhoneNos"};
$.ajax({
type: "GET",
url: "controllers/Customer.controller.php",
data: param,
success: function(result){
alert('success');
}
});
},
it alerts but autocomplete doesn’t work, I try to put the values in a text file and make the file in the url , the autocomplete works!!
Any explanation?!
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-use-the-jquery-ui-autocomplete-widget/
This is a tutorial on using the autocomplete plugin. The
responsevariable in your callback is a function that you can call to add an array of items to the autocomplete list. Parseresultand push each item onto an array, then callresponse(array);If result is already an array, you can callresponse(result);