function checkXmlHttpRequest()
{
var xmlHttp = false;
if (window.XMLHttpRequest)
{
return new XMLHttpRequest(); //To support the browsers IE7+, Firefox, Chrome, Opera, Safari
}
else if(window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP"); // For the browsers IE6, IE5
}
else
{
alert("Error due to old verion of browser upgrade your browser");
}
}
var xhr = new checkXmlHttpRequest(); //xhr holds the ajax object
function postToServlet()
{
if(xhr)
{
var company_to = document.getElementById("comp_to").value;
var subject = document.getElementById("comp_subject").value;
var complaint = document.getElementById("comp_letter").value;
var dateTime = document.getElementById("date_time").value;
if(company_to==""||subject==""||complaint==""||dateTime=="")
{
document.getElementById("redSignal").style.display='block';
document.getElementById("redSignal").innerHTML="All Fields are necessary";
}
else
{
xhr.open("POST","complaintHandler",true);
xhr.onreadystatechange = handlePostToServlet;
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var dataString="to="+company_to+"&subject="+subject+"&complaint="+complaint+"&dateTime="+dateTime;
xhr.send(dataString);
}
}
}
function handlePostToServlet()
{
if (xhr.readyState == 4)
{
if(xhr.status == 200)
{
document.getElementById("greenSignal").style.display='block';
document.getElementById("greenSignal").innerHTML=xhr.responseText;
}
else
{
document.getElementById("redSignal").style.display='block';
document.getElementById("redSignal").innerHTML="Error Code ="+xhr.status;
}
}
}
I am encountering an issue with error code 404 What could be causing this problem in the code? Any assistance is appreciated.