【问题标题】: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我使用 javascript 和 ajax 创建了一个在线打字测试页面。该代码在 google chrome firefox 中运行良好,但在 Internet Explorer 中运行良好
【发布时间】:2015-02-22 18:17:34
【问题描述】:

在 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 中查看此链接 http://www.geekzgarage.com/typing-test/ 并单击刷新图像。您每次都会看到随机单词。但在 IE 中,每次刷新后都会出现相同的单词。注意:这个问题可能已经在上面提到的链接上解决了。

【问题讨论】:

  • 可能是缓存。尝试在每次通过 XHR 请求的 URL 中添加一个随机 GET 参数。

标签: javascript ajax internet-explorer


【解决方案1】:

可能是对getdata.php 的请求被浏览器缓存了。 尝试在 URL 末尾添加时间戳。

【讨论】:

  • 我没有得到。能具体点吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-25
  • 1970-01-01
  • 2013-09-27
  • 1970-01-01
  • 2012-08-25
  • 2020-08-26
  • 1970-01-01
相关资源
最近更新 更多