How can I check if an Ajax request failed to load a file?
Here is the code I'm currently using:
var pro = undefined;
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
pro = JSON.parse(xmlhttp.responseText);
}
}
xmlhttp.open("GET","data.json",true);
xmlhttp.send();
Please note that I am not using jQuery.
Thank you!