Website. AJAX and FIREFOX problems. I dont think Firefox likes ajax..?

Posted by DJDonaL3000 on Stack Overflow See other posts from Stack Overflow or by DJDonaL3000
Published on 2010-04-06T09:14:03Z Indexed on 2010/04/06 9:33 UTC
Read the original article Hit count: 259

Filed under:
|
|
|
|

Working on an AJAX website (HTML,CSS,JavaScript, AJAX, PHP, MySQL). I have multiple javascript functions which take rows from mysql, wrap them in html tags, and embed them in the HTML (the usual usage of AJAX).

THE PROBLEM:

Everything is working perfect, except when I run the site with Firefox (for once its not InternetExplorer causing the trouble).

The site is currently in the developmental stage, so its offline, but running on the localhost (WampServer, apache, Windows XP SP3,VISTA,7).

All other cross-browser conflicts have been removed, and works perfectly on all major browsers including IE, Chrome, Opera and Safari, but I get absolutely nothing from the HTTPRequest (AJAX) if the browser is Firefox.

All browsers have the latest versions.

THE CODE:

I have a series of javascript functions, all of which are structured as follows:

function getDatay(){
  var a = document.getElementById( 'item' ).innerHTML;
  var ajaxRequest;
     try{//Browser Support Code:
      // code for IE7+, Firefox, Chrome, Opera, Safari:
      ajaxRequest = new XMLHttpRequest();
     } catch (e){
          // code for IE6, IE5:
      try{
       ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
       try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e){
        // Something went wrong
        alert("Your browser is not compatible - Browser Incompatibility Issue.");
        return false;
       }
      }
     }
     // Create a function that will receive data sent from the server
     ajaxRequest.onreadystatechange = function(){
      if(ajaxRequest.readyState < 4){
          document.getElementById( 'theDiv' ).innerHTML = 'LOADING...';
      }
          if(ajaxRequest.readyState == 4){
                      document.getElementById( 'theDiv' ).innerHTML =  ajaxRequest.responseText;
      }
     }
     //Post vars to PHP Script and wait for response:
     var url="01_retrieve_data_7.php";
          url=url+"?a="+a;
     ajaxRequest.open("POST", url, false);//must be false here to wait for ajaxRequest to complete.
     ajaxRequest.send(null);
}

My money is on the final five lines of code being the cause of the problem.

Any suggestions how to get Firefox and AJAX working together are most welcome...

© Stack Overflow or respective owner

Related posts about web-development

Related posts about AJAX