What am I doing wrong in this? When I run this on browser I am not getting output as 200 and ok.
Xmlhttprequest object in Java script.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Brijendra GautamRank #1,900 · 778 reputationPosted Mar 22, 2014, 5:58 PM EDT
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.