Jquery – Updating select box options via jQuery AJAX

ajaxjqueryplugins

Is there some type of plugin to do this? The server will return JSON content containing the option labels and values.

I can do this manually, I just wanted to see if there was an easier way.

Best Solution

Loop through the json and do this on each text/value pair (works cross-browser nicely):

var opt = document.createElement('option');
opt.value = "someValue";
opt.appendChild(document.createTextNode("someText"));
$('#mySelect').append(opt);