我的脚本适用于Chrome。我在Edge和IE10中遇到了一些困难。我把它缩小到下面的脚本。经过一些测试后,它可以在Edge中运行,但仍然不在IE10中
JS Library:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
JS
function scrollhandler() {
$.getJSON("check_time_scroll.php", function(update) {
if (update.count===true) {
alert("Update available");
}
});
}
setInterval(scrollhandler, 10000);
其他信息:
check_time_scroll.php
检查数据库中是否有新的相关内容。如果有,我会收到true
,如果true
我将内容加载到<div>
。
出于测试目的,我已将<div>
加载脚本替换为alert
。
我使用错误的图书馆有可能吗?在Edge中,警报测试有效,但不会使用原始脚本将内容上载到<div>
。
原始剧本:
function scrollhandler() {
$.getJSON("check_time_scroll.php", function(update) {
if (update.count===true) {
$("#scrolltext").load('unifoscrolltext.php');
}
});
}
setInterval(scrollhandler, 10000);
答案 0 :(得分:4)
可能IE10的缓存信息有问题。
function scrollhandler() {
var d = new Date();
var cache = d.getTime();
$.getJSON("check_time_scroll.php?cache=" + cache, function (update) {
if (update.count === true) {
$("#scrolltext").load('unifoscrolltext.php?cache=' + cache);
}
});
}
setInterval(scrollhandler, 10000);