I thought jQuery was supposed to resolve cross browser issues. Anyway I have some code that works just fine in IE9, Firefox and Chrome but not in IE8. All I am tryon to do is load a select tag with options. I have the following select tag on the page:
<select id="Select0"></select>
And the jQuery (1.7):
$(document).ready(function () {
$.ajax({
type: "POST",
url: "myPage.aspx/MyWebMethod",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: function (states) {
var jsonCodes = JSON.parse(states.d);
for (var i in jsonCodes) {
$("#Select0").append(new Option(jsonCodes[i].regionname, jsonCodes[i].region_id));
}
}
});
I need this to work in IE8 also or find another way to code it that will work in all browsers.
Thanks
IE7 doesn’t support
JSON.parse. jQuery of course has a solution to this issue. Try this:Update:
I can’t get
$(element).append(new Option(x,y));to work in IE8. The option gets appended with no label. http://jsfiddle.net/7qfhg/. Try changing to this syntax http://jsfiddle.net/7qfhg/3/: