Hello guys, tried googling or searching in this forum but it will still not work. This code works perfectly fine in IE but not in firefox. Here's the AJAX code:

function search()
{
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("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","search.php",true);
xmlhttp.send();
}

This is search.php

<?php
echo "hey";
?>

I've spent 2 hours on this. I would really appreciate it if you guys can tell me what the problem is

Hi Whilliam,

I have checked it in IE and firefox. It works fine here. What firefox version are you using? And do you have any other javascript code exists in that page other than the search function?

hello, sorry for the late reply. The firefox version was 1.something. I tried testing it in newer version of firefox and it worked well.

Old versions of firefox had a proprietary dom, new versions have a simliar dom to IE safari, just a way better implementation than IE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.