Whats wrong with this AJAX Code? Not working in FireFox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqasmgl
    New Member
    • Nov 2007
    • 20

    Whats wrong with this AJAX Code? Not working in FireFox

    Hi,
    I m confused about following ajax code. Where is the problem? Working good on IE but not on FireFox?

    Please sort it out.

    Code:
    <script type="text/javascript">
    function loadXMLDoc()
    {
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("myDiv").innerHTML="hello";
        }
      }
    xmlhttp.open("GET","index.aspx?id=abc",true);
    xmlhttp.send();
    }
    </script>
    Thanx in advance.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    first try an alert before setting the innerHTML ... to see whether the callback is called correctly ... next check whether document.getEle mentById("myDiv ") returns you the correct node ... you might consider installing the firebug extension to FF where you instantly should see any errors

    kind regards

    Comment

    Working...