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 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题