jQuery-- Populate select from json -


i have map in java sevlet , converting json format works right.

when function below creates drop down, puts every character option?? got:

$(document).ready(function(){     var temp= '${temp}';     //alert(options);     var $select = $('#down');                             $select.find('option').remove();                               $.each(temp, function(key, value) {                       $('<option>').val(key).text(value).appendto($select);          }); }); 

map content in json format

{"1" : "string","2" : "string"} 

i this:

$.each(temp,function(key, value)  {     $select.append('<option value=' + key + '>' + value + '</option>'); }); 

json structure appreciated. @ first can experiment find('element') - depends on json.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

What is the difference between data design and data model(ERD) -

ios - Can NSManagedObject conform to NSCoding -