I have the following piece of code (only relevant parts):
xhttp=new XMLHttpRequest();
xhttp.open("GET",doc_name,false);
xhttp.send();
xmlDoc=xhttp.responseXML;
if(xmlDoc==null)
{
xmlDoc=loadXMLDoc(defaultXml);
}
This runs fine as I load a default xml file if the specified file does not exist but shows a 404 error only in the console if the file does not exist. (This error does not reflect anywhere in the page except the console).
My question is that how should I check for this exception & is it necessary to add an extra piece of code for checking the existence of the file when the code runs without it?