dongxin2734 2012-09-12 15:55
浏览 89

IE8中的AJAX请求失败

As per usual I've found an incompatibility issue with my code when using IE8. I have 3 tier AJAX drop down menu system, each of which pulls its results from a MYSQL database and is working fine in all browsers. However, the third drop down then triggers a final AJAX request which works fine in all browsers and all versions (that I've tested) with the exception of IE8, which instead of changing the content of my final div just makes an error appear.

My AJAX function which is called by showResult(this.value):

    function showResult(str)
    {
    if (str=="")
    {
       document.getElementById("resultChange").innerHTML="";
       return;
    }
    if (window.XMLHttpRequest)
    {
        xmlhttp=new XMLHttpRequest();
    }
    else
      {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("resultChange").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","checker.php?z="+str,true);
    xmlhttp.send();
    }

The relevant code from checker.php:

    if(isset($_GET["z"])){
    $z=$_GET["z"];

    require_once('db connection here');

    $sql3="mysql query here";

    $result3 = mysql_query($sql3);

    $count3 = mysql_num_rows($result3);
    if($result3 > 0){

    while($row3 = mysql_fetch_array($result3))
      {
      echo "Display this if it works";  }

    }
    else
    { echo  'Error';}

    unset($_GET["z"]);  
    mysql_close(); 
     }

And, just in case it matters, this is the DIV to be affected:

    <div id="resultChange" align="left" valign="top" style="margin: 0px;">Test
    </div>

The other AJAX requests on the page are identical in both their call to function and their relevant parts in the checker.php file, with the exceptions of their $_GET assignments and the ids of the divs. Oh, and they all work fine even in IE8!

I hope someone can help as I can't find anything wrong with it!

Thanks, Joe

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度