gpt4 book ai didi

javascript - JQuery 脚本在 IE 8 上运行失败

转载 作者:行者123 更新时间:2023-11-28 19:58:50 25 4
gpt4 key购买 nike

我刚刚编写了一些 JQuery 脚本来练习访问 JSON 数据,它在 Firefox、Chrome 和 IE 11 上完美运行。但是,它在 IE 8 上运行失败,并显示以下错误消息:

Message: Object doesn't support this property or method
Line: 2
Char: 29489
Code: 0
URI: http://code.jquery.com/jquery-2.1.0.min.js


Message: '$' is undefined
Line: 12
Char: 4
Code: 0

是因为 JQuery 2.x 停止支持 IE 8 吗?根据http://jquery.com/browser-support/ ,还是其他原因?我想不明白。

有人有任何提示吗?提前致谢。

代码如下:

    <!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
</head>
<body>
<div id="div1">dv1</div>

<script type="text/javascript">
function getData(){
$.ajax({
type:"GET",
url:"j.json",
dataType:"json",
success: function(jsondata){
output(jsondata);
}
});
}

function output(json){

//var Data = eval('(' + json + ')');
var html = '';
//alert(Data.length);
for(var i=0;i<json.length;i++){
html += ' name:' + json[i].name + ' age:' + json[i].age;
}

document.getElementById('div1').innerHTML = html;

}

setInterval(getData, 3000);

</script>
</body>
</html>

最佳答案

jQuery 2.0 不支持 IE8 或更早版本。您必须使用 jQuery 的某个 1.x 版本。

关于javascript - JQuery 脚本在 IE 8 上运行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22057444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com