I need to feed cities based on country of selection. I did it programmically but have no idea how to put JSON data into the select box. I tried several ways using jQuery, bu
Given returned json from your://site.com:
[{text:"Text1", val:"Value1"}, {text:"Text2", val:"Value2"}, {text:"Text3", val:"Value3"}]
Use this:
$.getJSON("your://site.com", function(json){ $('#select').empty(); $('#select').append($('').text("Select")); $.each(json, function(i, obj){ $('#select').append($('').text(obj.text).attr('value', obj.val)); }); });