I am trying to take a JSON string and create a dropdown with it. What I see all over the place is to use parseJSON with a map function to do this.
I cannot make it work. I keep getting the following error:
*************************************************************
Unhandled exception at line 1409, column 2 in
0x800a138f - JavaScript runtime error: Unable to get property 'ownerDocument' of undefined or null reference
**************************************************************
This is the JQuery line that the parseJSON is working with (got this from the watch window).
"[{\"Disabled\":false,\"Group\":null,\"Selected\":false,\"Text\":\"Tustin, Orange\",\"Value\":\"7636dc65-5b08-4af8-b3a5-970800c59511\"}]"
I finally got it to work another way where I parsed it first and didn't use the "map" function:
Using test3 where I already did the parseJSON on it, does not work with the map fuction:
And using the parseJSON as part of the statement does not work:
Anyone know what is causing the error?
Thanks,
Tom
I cannot make it work. I keep getting the following error:
*************************************************************
Unhandled exception at line 1409, column 2 in
0x800a138f - JavaScript runtime error: Unable to get property 'ownerDocument' of undefined or null reference
**************************************************************
This is the JQuery line that the parseJSON is working with (got this from the watch window).
"[{\"Disabled\":false,\"Group\":null,\"Selected\":false,\"Text\":\"Tustin, Orange\",\"Value\":\"7636dc65-5b08-4af8-b3a5-970800c59511\"}]"
I finally got it to work another way where I parsed it first and didn't use the "map" function:
Code:
var test3 = $.parseJSON(data);
$(test3).each(function () {
$('#PersonalDetail_CityCountyDisplay').append($('<option>').val(this.Value).text(this.Text));
});
Using test3 where I already did the parseJSON on it, does not work with the map fuction:
Code:
$(test3).map(function () {
return $('<option>').val(this.Value).text(this.Text);
}).appendTo('#PersonalDetail_CityCountyDisplay');
And using the parseJSON as part of the statement does not work:
Code:
$($.parseJSON(data)).map(function () {
return $('<option>').val(this.Value).text(this.Text);
}).appendTo('#PersonalDetail_CityCountyDisplay');
Anyone know what is causing the error?
Thanks,
Tom