我使用 javascript 和 ajax 创建了一个在线打字测试页。该代码在 google chrome firefox 中运行良好,但在 Internet Explorer 中运行不正常
i have created a online typing test page using javascript and ajax. the code is working fine in google chrome firefox, but not in internet explorer
在 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
块中将单词分开。整个代码在所有浏览器中都能正常工作(即收到随机段落),但在 Internet Explorer 中,第一次加载的同一段落会一次又一次收到。
我完全不明白为什么它在 IE 中不起作用。如果有人有想法,请告诉我为什么会这样,需要进行哪些修改。
有关问题的更多说明,请检查 chrome 中的 link http://www.geekzgarage.com/typing-test/ 并单击刷新图像。您每次都会看到随机单词。但在 IE 中,每次刷新后都会出现相同的词。注意:这个问题可能已经在上面提到的link上解决了。
可能是 getdata.php 的请求被浏览器缓存了。
尝试在 URL.
的末尾添加时间戳
在 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
块中将单词分开。整个代码在所有浏览器中都能正常工作(即收到随机段落),但在 Internet Explorer 中,第一次加载的同一段落会一次又一次收到。
我完全不明白为什么它在 IE 中不起作用。如果有人有想法,请告诉我为什么会这样,需要进行哪些修改。
有关问题的更多说明,请检查 chrome 中的 link http://www.geekzgarage.com/typing-test/ 并单击刷新图像。您每次都会看到随机单词。但在 IE 中,每次刷新后都会出现相同的词。注意:这个问题可能已经在上面提到的link上解决了。
可能是 getdata.php 的请求被浏览器缓存了。 尝试在 URL.
的末尾添加时间戳