I have an error with AJAX xml response. When I call function get_res_table() I'm getting error as in the header.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Actions</title>
</head>
<body>
<fieldset>
<legend>Actions</legend>
<label>Pick Search:</label>
<form name="form1" method="get">
<select id="Show" name="Show">
<option selected value="0">Nurse wards</option>
<option value="1">Wards by department</option>
<option value="2">Wards by shift</option>
</select>
<input type="button" value="Select search type" onClick="javascript: gets2();"/>
<div id="Search_type" style="display: none;">
<hr/>
<label>Pick object:</label>
<select id="Search_val" name="Search_val">
</select>
<input type="button" value="Find" onClick="javascript: gets_res_table();"/>
<hr />
</div>
<div id="date"></div>
<div id="department"></div>
<div id="shift"></div>
</form>
</fieldset>
</body>
</html>
<script type="text/javascript">
function gets2()
{
if (!ajax)
{
alert("Ajax not initialized");
return;
}
var s1val = document.getElementById("Show").value;
ajax.onreadystatechange = UpdateSelect2;
ajax.open("GET", "select.php?select1="+s1val, true);
ajax.send('localhost');
}
</script>
<script type="text/javascript">
var ajax;
InitAjax();
function InitAjax()
{
try
{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
try
{
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
ajax = new XMLHttpRequest();
}
catch (e)
{
ajax = 0;
}
}
}
}
</script>
<script type="text/javascript">
function UpdateSelect2()
{
if (ajax.readyState == 4)
{
if (ajax.status == 200)
{
var divBody = document.getElementById('Search_val');
divBody.innerHTML = ajax.responseText;
document.getElementById('Search_type').style.display = "block";
}
else alert(ajax.status + " - " + ajax.statusText);
ajax.abort();
}
}
</script>
<script type="text/javascript">
function gets_res_table()
{
if (!ajax)
{
alert("Ajax not initialized");
return;
}
var s1val = document.getElementById("Show").value;
var obj = document.getElementById("Search_val").value;
ajax.onreadystatechange = UpdatePage;
ajax.open("GET", "result.php?select1="+s1val+"&obj="+obj, true);
ajax.send('localhost');
}
</script>
<script type="text/javascript">
function UpdatePage()
{
if(ajax.readyState == 4)
{
if(ajax.status == 200)
{
xmlDoc=ajax.responseXML;
document.getElementById("date").innerHTML =
xmlDoc.getElementsByTagName("date")[0].childNodes[0].nodeValue;
document.getElementById("department").innerHTML =
xmlDoc.getElementsByTagName("department")[0].childNodes[0].nodeValue;
document.getElementById("shift").innerHTML =
xmlDoc.getElementsByTagName("shift")[0].childNodes[0].nodeValue;
}
}
else
{
alert(ajax.status + " - " + ajax.statusText);
ajax.abort();
}
}
</script>
It worked some time when I was executing it in another(New) project or something like that. But now it don't works at all and always throws me such error.