douao3063 2013-04-29 05:39
浏览 184

远程服务器上的XmlHttpRequest status = 0,localhost上的状态200

I have two nearly identical PHP proxy scripts that I call through nearly identical JS. The first works fine in all scenarios.

The second (code below) works on my localhost IIS server in both Firefox and Chrome. On the remote Glassfish Apache server, it works in Firefox, but returns status = 0 with empty return in Chrome (tested in v22 & v26). The two PHP proxy scripts are virtually identical and download similar length data (between 1 and 4 MB). With the following JS, the else and onerror alerts are both triggered.

var dateQueryText = interviewDays[exitDay];
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
    if (xmlhttp.readyState == 4){
        if (xmlhttp.status == 200){
            var xmlDoc=xmlhttp.responseXML;
            processGPX(xmlDoc);
        }
        else{alert("Download of GPS data failed for date " + dateQueryText + " Status: " + xmlhttp.status);} 
    }
}
xmlhttp.onerror = function (e){alert("Error encountered and download of GPS data failed for date " + dateQueryText + " Status: " + xmlhttp.status);};

xmlhttp.open("POST","proxy2.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
params = ("case=" + caseID + "&gps=true" + "&date=" + dateQueryText);
xmlhttp.send(params);

I've tried the following to no avail:

  • async & synchronous downloads
  • overriding the return type, since GPX (GPS data in XML format) isn't always understood by servers {xmlhttp.overrideMimeType("text/xml");}.
  • providing the full path to the PHP script

What could be causing the problem in Chrome?

EDIT: Here is the request header for the failing PHP request. There is no response received.

Request URL: https://www.XXX.edu/AAA/BBB/CCC/proxy2.php

Request Headers
Cache-Control:no-cache
Content-type:application/x-www-form-urlencoded
Origin:https://www.XXX.edu
Pragma:no-cache
Referer:https://www.XXX.edu/AAA/BBB/CCC/exitgraphic.php?case=TESTCASE&instrument=0001&mode=TEST
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Ubuntu/12.10 Chromium/22.0.1229.94 Chrome/22.0.1229.94 Safari/537.4

Form Data
case:TESTCASE
inst:0001
mode:TEST
gps:true
date:02222013
  • 写回答

1条回答 默认 最新

  • dongzhi4470 2013-04-29 19:32
    关注

    Can you re-try the failing request with Chrome's Developer Tools (Tools --> Developer Tools) activated and post here the headers of the request and the response (in the Network tab), and any error message in the Console tab?

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)