I have the following jQuery code. I am able to get the following data from server [{\"value\":\"1\",\"label\":\"xyz\"}, {\"value\":\"2\",\"label\":\"abc\"}]. Ho
This should do the trick:
$($.parseJSON(data.msg)).map(function () {
return $('
Here's the distinction between ajax and getJSON (from the jQuery documentation):
[getJSON] is a shorthand Ajax function, which is equivalent to:
$.ajax({ url: url, dataType: 'json', data: data, success: callback });
EDIT: To be clear, part of the problem was that the server's response was returning a json object that looked like this:
{
"msg": '[{"value":"1","label":"xyz"}, {"value":"2","label":"abc"}]'
}
...So that msg property needed to be parsed manually using $.parseJSON().