标题:FireFox不支持Ajax的问题
只看楼主
乃别亚
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2010-7-29
结帖率:50%
已结贴  问题点数:0 回复次数:3 
FireFox不支持Ajax的问题
创建XmlHttpRequest声明:
var req;
function ajaxFunction()
{
try
   {
  // Firefox, Opera 8.0+, Safari
    req=new XMLHttpRequest();
   }
catch (e)
   {
 // Internet Explorer
  try
     {
      req=new ActiveXObject("Msxml2.XMLHTTP");
     }
  catch (e)
     {
     try
        {
         req=new ActiveXObject("Microsoft.XMLHTTP");
        }
     catch (e)
        {
        alert("您的浏览器不支持AJAX!");
        return false;
        }
     }
   }
}
function checkUserUid()
{
    var uid = document.getElementById("uid").value;
    var uidString = "uid=" + uid;
    uidString = uidString + "&method=checkUserUid";   
    var url = "../../HomePageAction.action";
         ajaxFunction();
         if (req) {
             req.open("POST", url, true);
             req.onreadystatechange = callbackUid;
             req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
             req.send(uidString);
         } else {
         document.write("xmlHttpReqest对象创建失败");        
         }
}

function callbackUid() {
    if (req.readyState == 4) {
        if (req.status == 200) {
            var count = req.responseText;
            var chk_signup_uid = document.getElementById("chk_signup_uid");
            var infodisplay = "<font>用户名已经存在,请使用其他用户名</font>";
            var infodisplay1 = "<font>由英文字母、数字或下划线组成,并以英文字母开头。</font>";
            var infodisplay2 = "由英文字母、数字或下划线组成,并以英文字母开头。";
            if (count == 0) {               
                var uid = document.getElementById("uid").value;
                if (uid == "") {
                    document.getElementById("chk_signup_uid").innerHTML = infodisplay2;
                    return false;
                } else if (!/^\w+$/.test(uid)) {
                    document.getElementById("chk_signup_uid").innerHTML = infodisplay1;
                    return false;
                } else if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(uid)) {
                    document.getElementById("chk_signup_uid").innerHTML = infodisplay1;
                    return false;
                }
                   document.getElementById("chk_signup_uid").innerHTML = "成功";      
            } else if(count == 1){         
                   document.getElementById("chk_signup_uid").innerHTML = infodisplay;
            }         
        }      
    }
    else
    {
        document.getElementById("chk_signup_uid").innerHTML = "检测中...";
    }
 }
是不是我的JS有问题?FireFox支持JS,Ajax有什么要求呢?为什么IE支持而FireFox不支持,请大虾指点。

[ 本帖最后由 乃别亚 于 2010-8-3 13:15 编辑 ]
搜索更多相关主题的帖子: Ajax FireFox 
2010-07-30 10:49
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
得分:7 
没有问题!

★★★★★为人民服务★★★★★
2010-08-03 06:22
wtuaimmmm
该用户已被删除
得分:7 
提示: 作者被禁止或删除 内容自动屏蔽
2010-08-06 09:17
beidoujs
Rank: 2
等 级:论坛游民
帖 子:21
专家分:12
注 册:2011-3-31
得分:0 
楼上说的在理。

知己知彼
2011-05-24 07:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-314381-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028122 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved