I’m getting JSON back in this format from my C# webmethod:
{"d":["ADAMS CITY","BOULDER","ANTON","ARBOLES"]}
I now have a asp.net dropdown. Well, it renders as a html dropdown with #city id.
I’m getting a success alert on my AJAX request. How can I populate these results into my #city dropdown?
Tried this:
success:
function (data) {
var values = eval(data.d);
var ddl = $("#parkCity");
$('option', ddl).remove();
ddl.html(data);
alert("Cities loaded");
},
Here’s something that should do fine inside of your
successcallback:Example: http://jsfiddle.net/z2D8f/
Or an alternative that appends the HTML all at once, which is probably faster:
Example: http://jsfiddle.net/pUhw2/