Problem in getting Http Response in chrome

Posted by Bhaskasr on Stack Overflow See other posts from Stack Overflow or by Bhaskasr
Published on 2010-04-05T06:05:39Z Indexed on 2010/04/05 7:33 UTC
Read the original article Hit count: 230

Filed under:
|

Am trying to get http response from php web service in javascript, but getting null in firefox and chrome. plz tell me where am doing mistake here is my code,

function fetch_details()
{
 if (window.XMLHttpRequest)
 {
  xhttp=new XMLHttpRequest()
  alert("first");
 }
else
 {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP")
  alert("sec");
 }
 xhttp.open("GET","url.com",false);
 xhttp.send("");
 xmlDoc=xhttp.responseXML;
 alert(xmlDoc.getElementsByTagName("Inbox")[0].childNodes[0].nodeValue);
}

I have tried with ajax also but am not getting http response here is my code, please guide me

var xmlhttp = null;
var url = "url.com"; 
if (window.XMLHttpRequest) 
{ 
   xmlhttp = new XMLHttpRequest(); 
   alert(xmlhttp); //make sure that Browser supports overrideMimeType 
   if ( typeof xmlhttp.overrideMimeType != 'undefined') 
   {                     
      xmlhttp.overrideMimeType('text/xml'); 
   } 
} 
else if (window.ActiveXObject) 
{ 
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{ 
   alert('Perhaps your browser does not support xmlhttprequests?'); 
} 

xmlhttp.open('GET', url, true);
xmlhttp.onreadystatechange = function() {

if (xmlhttp.readyState == 4)
{
   alert(xmlhttp.responseXML);
} 
};

}

// Make the actual request xmlhttp.send(null);

I am getting xmlhttp.readyState = 4 xmlhttp.status = 0 xmlhttp.responseText = ""

plz tell me where am doing mistake

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about xmlhttprequest