v_kavvadias
Posts: 0
Joined: Mon Mar 10, 2014 8:46 pm

Update select menu via ajax call

Hi.I am trying to update a select menu, based on another select menu value via ajax call.The code is this.

var value = this.value;
$.ajax({
type: "GET",
beforeSend: function(request) {
request.setRequestHeader("X-Appery-Database-Id", "xxxxxxxxxxxxxxxxxx");
},
url: "https://api.appery.io/rest/1/db/colle...",
data: {
where: '{"FoodId":{"$regex":"^'+value+'"}}'
},
dataType: "json",
success: function(response) {
var items = '';
$.each(response,function(name,value) {
var dropDown = $('FoodSubCategory');//The name of select menu to be updated
items += ""+value.GrName+"";
dropDown.append(items);
dropDown.selectmenu('refresh');
});
},
error: function(xhr, ajaxOptions, thrownError) {
console.log("Load error: " + xhr.status + " " + xhr.responseText);
}
});

I have checked the response and its working ok but the select menu 'FoodSubCategory' is not updated.
Please help.

items += ""+value.GrName+"";

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Update select menu via ajax call

Hello.

This block of code is wrong:
pre

Code: Select all

     var items = ''; 
     $.each(response, function(name, value) { 
         var dropDown = $('FoodSubCategory'); //The name of select menu to be updated  
         items += "" + value.GrName + ""; 
         dropDown.append(items); 
         dropDown.selectmenu('refresh'); 
     }); 

/pre
Please check this to create correct code: http://docs.appery.io/tutorials/build...

v_kavvadias
Posts: 0
Joined: Mon Mar 10, 2014 8:46 pm

Update select menu via ajax call

OK thanks

Return to “Issues”