在 Internet Explorer 中,当我刷新单词时,会再次收到相同的响应。 这是在 onclick 事件上刷新单词列表的函数。
function refresh() {
// divs in which words to be set
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
/*
------------
-----------
logic in which words are received from database in a para and then separated and inserted in
div where words are to be displayed.
-----------
-----------
*/
}
xmlhttp.open("GET","getdata.php",true);
xmlhttp.send();
}// refresh
在getdata.php
中,从数据库中随机选择一个段落,然后在上面的if
block 中分隔单词。整个代码在所有浏览器中都能正常工作(即收到随机段落),但在 Internet Explorer 中,第一次加载的同一段落会一次又一次地收到。
我完全困惑为什么它在 IE 中不起作用。如果有人有想法,请告诉我为什么会发生这种情况以及需要进行哪些修改。
有关该问题的更多说明,请查看此链接 http://www.geekzgarage.com/typing-test/在 Chrome 中,然后单击刷新图像。您每次都会看到随机单词。但在 IE 中,每次刷新后都会出现相同的单词。注意:这个问题可能已经在上面提到的链接上得到解决。
最佳答案
可能是对 getdata.php 的请求被浏览器缓存了。 尝试在 URL 末尾添加时间戳。
关于javascript - 我使用 javascript 和 ajax 创建了一个在线打字测试页面。该代码在 google chrome firefox 中运行良好,但在 Internet Explorer 中运行不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28661449/