Hello everyone, I am trying to write a simple web application where I have a mySQL table. I am using drop down menus to select options on how to filer the table.... i.e. select the subject, filter the table for just that subject and continue on. Anyways I'm trying to use AJAX. I went to w3schools and literally copied and pasted the code... it seems to be working for them but my xmlhttp.onreadystatechange=function() does not want to get called or go through. I was wondering if someone could help me because I've been at it for a couple hours with no luck.
$script = "<script language='Javascript' type='text/javascript'>
function loadTopics()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById('Topics').innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open('GET','loadTopics.php',true);
xmlhttp.send();
}
</script>";
echo $script;
I posted a number of different alert messages and know that it is where the onstatereadychange=function the error must be occurring. Or at least, as far as I have deduced...
The HTML code looks something like this (so far).
<div id='Topics'> <select> </select> </div>
Thanks in advance.