What am I doing wrong in this? When I run this on browser I am not getting output as 200 and ok.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Brijendra GautamPosted Mar 22, 2014, 9:58 PM
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.google.com/", false);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) { // Ajax call completed
alert(xhr.responseText); //Response from Ajax call
if(xhr.status==200){ // No error
// xhr.responseXML ----use this property to get the XML value.
}
}
}
xhr.send();
Status =200 and OK means your request processed successfully and response is sent back to you.