dqq9695 2010-04-06 09:14
浏览 61
已采纳

网站。 AJAX和FIREFOX问题。 我不认为Firefox喜欢ajax ..?

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...

  • 写回答

3条回答 默认 最新

  • douzhuoxia0587 2010-04-06 09:23
    关注

    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());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试