无法将url响应捕获到字符串中

时间:2013-09-03 13:57:38

标签: javascript ajax

我在点击该URL时有一个HTTP URL我在浏览器中获得START = ST | URL = NHNG | URLC =的响应。 我试着用javascript命中并捕获响应。但是无法用Ajax做到这一点。 responseXML和text返回null。 我的目标是点击URL并将响应标记为不同的字符串,如St,NHNG和https://www.google.com。并使用它们[/ p>]

请建议继续进行。谢谢。 网址我不能在防火墙旁边。所以无法提供url.But在浏览器中我们得到上面指定的响应,同时击中网址 我使用的当前代码是`

function state_Change(){
if (xmlhttp.readyState==4){
if (xmlhttp.status==200){
alert("Before");
// document.getElementById("cnu").innerHTML = "nnnn";
res= xmlhttp.responseText;
alert(res);
// ...our code here...
}else{
alert("Problem retrieving data");
}}
}
function loadXMLDoc(url)
{
alert("Ajax");
    xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for all new browsers
      xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5 and IE6
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
      xmlhttp.onreadystatechange=state_Change;
      xmlhttp.open("GET",url,true);
      xmlhttp.send(null);
  }
else
  {
      alert("Your browser does not support XMLHTTP.");
  }
}

`

0 个答案:

没有答案