【发布时间】:2012-03-19 21:49:21
【问题描述】:
我认为 jQuery 应该解决跨浏览器问题。无论如何,我有一些在 IE9、Firefox 和 Chrome 中运行良好但在 IE8 中运行良好的代码。我要做的就是加载带有选项的选择标签。我在页面上有以下选择标签:
<select id="Select0"></select>
还有 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));
}
}
});
我需要它也可以在 IE8 中工作,或者找到另一种可以在所有浏览器中工作的编码方式。 谢谢
【问题讨论】:
-
从 jQuery 中受益的唯一方法是使用 jQuery。您混合了本机代码和 jQuery。这也很好,但是你需要知道兼容性问题。
-
I thought jQuery was supposed to resolve cross browser issues- 但在您的示例中,不仅有 jQuery,还有可能导致问题的JSON对象和for循环 -
我应该改用 jQuery.getJSON() 吗?
标签: jquery internet-explorer-8 internet-explorer-9