auto complete is working fine. I put a hidden value for saving the value of auto complete by this method my code :
$("#cityOp").autocomplete({
source : function(request, response) {
var city_value = jQuery("#cityOp").val();
$.ajax({
url: "city.html",
dataType: "json",
data : {
filter : city_value
},
success : function(data) {
response(jQuery.map(data.cities,function(item) {
return {
value : item.locationName,
key : item.locationId
};
}));
},
select : function(event, ui) {
$("#theHidden").val(ui.item.key) ;
}
});
then I want to get this location Id for saving the value of location , so I tried the as:
save(){
var locationValue=$("#theHidden").val();
//other saving codes
}
but I got here locationValue is undefined .
How I get the this hidden value in save function ? autocomplete function is in document on ready and save function is in a js.
save()function defined properly? With thefunctionkeyword? Is the value coming in and being set properly? Is it being set undefined in the first place, you can check in your browsers debugger.