特定计算机上的Ajax状态未达到200

时间:2012-12-05 14:48:49

标签: javascript ajax

我正在构建一个使用的Web应用程序,我认为它是一个简单的Ajax函数。该应用程序在办公室中的五台计算机中有四台很好用,但是一台计算机有一个问题达到了200的状态。它也不是一个特定于浏览器的问题。他在IEChromeFirefox和&所有四种浏览器都有Safari和同样的问题。

在产品投入全面生产之前,我们必须在结束时弄清楚并纠正这个问题。在此之后,我们无法绕过纠正客户的计算机或试图向客户解释他们的计算机是否有问题。

所有想法?

注意:

  1. Ajax函数,查询PHP脚本和数据库全部开启 同一台服务器。
  2. 他的电脑在Pavilion DV7上运行Windows 7 计算机
  3. 代码:

    // Pull the information from the database
    get_variables = 'action=grabUnitInformation'+
    '&identifier='+identifier;
    
    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){
        var receiver = eval('(' + xmlhttp.responseText + ')');
    
        // Process JSON
        alert("Got the info");
    }else{
        alert("Ready state: "+xmlhttp.readyState);
        alert("Status: "+xmlhttp.status);
    }
    }
    
    xmlhttp.open("GET", "http://www.mysite.com/search.php?"+get_variables, true);
    xmlhttp.send();
    

1 个答案:

答案 0 :(得分:0)

好的,我找到了一种方法让它发挥作用。

包含Ajax脚本,查询PHP脚本和数据库的页面都在同一台服务器上。所以..........

而不是绝对网址:

xmlhttp.open("GET", "http://www.mysite.com/search.php?"+get_variables, true);

我将其更改为相对网址:

xmlhttp.open("GET", "search.php?"+get_variables, true);

现在好了。可能不是最好的方式,但我还没有找到任何其他答案或帮助。