Ajax in Firefox not working

Discussion in 'JavaScript' started by mehdi, Feb 28, 2008.

  1. #1
    well this code is working in IE but not in Firefox...
    function getFile(pURL) {
       if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
          xmlhttp=new XMLHttpRequest();
          xmlhttp.onreadystatechange=postFileReady;
          xmlhttp.open("GET", pURL, true);
          xmlhttp.send(null);
       } else if (window.ActiveXObject) { //IE
          xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
          if (xmlhttp) {
             xmlhttp.onreadystatechange=postFileReady;
             xmlhttp.open('GET', pURL, true);
             xmlhttp.send();
          }
       }
    }
     
    // function to handle asynchronous call
    function postFileReady() {
       if (xmlhttp.readyState==4) {
          if (xmlhttp.status==200) {
             document.getElementById('theExample').innerHTML=xmlhttp.responseText;
          }
       }
    }
    getFile('http://example.com/example.html');
    Code (markup):
    any idea how to solve it??
     
    mehdi, Feb 28, 2008 IP
  2. Kylratix

    Kylratix Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What output do you get from Firebug?
     
    Kylratix, Feb 28, 2008 IP