I am quite new to javascript programming and I sending xmlhttprequest whose reply is in xml format. when I use a proxy and intercept the response, I can see the reply as expected and in xml format. however I want to retrieve the response and display the value in html or just some alert. But I am getting an error that xmlresponse is null. why is the value from xmlhttp.responseXML null. below is my code. please does anyone has an idea on what is wrong.
var xmlhttp=new XMLHttpRequest();
xmlhttp.open('GET','http://remoteserver.net/search/myvalues?format=xml','true');
xmlhttp.send();
alert(xmlhttp.responseText);
alert(xmlhttp.responseXML);
var xmlresponse=xmlhttp.responseXML;
var latitude;
var longitude;
try{
if(xmlhttp.status==200){
x=xmlresponse.getElementsByTagName("place");
latitude=x.getAttribute("lat");
longitude=x.getAttribute("lon");
coordonates="the latitude is "+latitude+" and the longitude is "+longitude;
//document.getElementById("output").innerHTML=coordonates;
alert(coordonates);
}
}
catch(err)
{
document.getElementById("output").innerHTML=err.message;
}
so far what this is what I have as information How to get the response of XMLHttpRequest? also http://www.w3schools.com/ajax/ajax_xmlhttprequest_response.asp