开发者

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

开发者 https://www.devze.com 2022-12-25 14:33 出处:网络
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

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开发者_C百科 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...


Had to post the jquery one-liner that bunch of code translates into!

$("#theDiv").text("LOADING...").load("01_retrieve_data_7.php?a="+$("#item").text());


Look at that : http://translate.google.fr/translate?js=y&prev=_t&hl=fr&ie=UTF-8&layout=1&eotf=1&u=http://www.siteduzero.com/tutoriel-3-100294-l-objet-xmlhttprequest.html&sl=fr&tl=en

Google messes up the codes so take a look at the french version for codes : http://www.siteduzero.com/tutoriel-3-100294-l-objet-xmlhttprequest.html


Before investigating your code, make sure to disable any firefox addons you've got installed. Both ABP and Firebug are known to interfere under certain circumstances when FF tries to execute js

0

精彩评论

暂无评论...
验证码 换一张
取 消