帮忙看看这段ajax怎么不兼容火狐浏览器
时间:2011-03-30
来源:互联网
function getxmlhttprequest(){
if(window.XMLHttpRequest){ //Mozilla
XMLHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
return XMLHttpReq;
}
function getcodevalue()
{
if(xmlhttp.readyState == 4)
{
var response = xmlhttp.responseText;
response=response.replace(/\s/g, "");
if(response=='')
{alert('对不起,您填写的资料有误或者刚咨询过,暂时不能提交!');document.getElementById('uname').value='',document.getElementById('phone').value='',document.getElementById('xm').value='';}
else
{alert('谢谢您的咨询,我们将尽快跟您电话联系!');document.getElementById('uname').value='',document.getElementById('phone').value='',document.getElementById('xm').value='';}
}
}
function addxm()
{
var uname,phone,xm;
uname=document.getElementById("uname").value;
phone=document.getElementById('phone').value;
xm=document.getElementById('xm').value;
if((uname=='')||(phone=='')||(xm=='')){alert('请填写完整的内容');document.getElementById('uname').focus();}
else
{
xmlhttp = getxmlhttprequest();
if(xmlhttp == null)
{
alert("浏览器不支持xmlhttprequest!");
return;
}
var url = "/zx.php?username="+uname+"&phone="+phone+"&xm="+xm+"&j="+ Math.round(Math.random()*100)+"&add=ok&curl="+location.href;
xmlhttp.open("GET",url,true);
xmlhttp.onreadystatechange=getcodevalue; //指定响应的函数
xmlhttp.send(null); //发送请求
}
}
function hidexm()
{
document.getElementById('xmform').style.display='none';
}
if(window.XMLHttpRequest){ //Mozilla
XMLHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
return XMLHttpReq;
}
function getcodevalue()
{
if(xmlhttp.readyState == 4)
{
var response = xmlhttp.responseText;
response=response.replace(/\s/g, "");
if(response=='')
{alert('对不起,您填写的资料有误或者刚咨询过,暂时不能提交!');document.getElementById('uname').value='',document.getElementById('phone').value='',document.getElementById('xm').value='';}
else
{alert('谢谢您的咨询,我们将尽快跟您电话联系!');document.getElementById('uname').value='',document.getElementById('phone').value='',document.getElementById('xm').value='';}
}
}
function addxm()
{
var uname,phone,xm;
uname=document.getElementById("uname").value;
phone=document.getElementById('phone').value;
xm=document.getElementById('xm').value;
if((uname=='')||(phone=='')||(xm=='')){alert('请填写完整的内容');document.getElementById('uname').focus();}
else
{
xmlhttp = getxmlhttprequest();
if(xmlhttp == null)
{
alert("浏览器不支持xmlhttprequest!");
return;
}
var url = "/zx.php?username="+uname+"&phone="+phone+"&xm="+xm+"&j="+ Math.round(Math.random()*100)+"&add=ok&curl="+location.href;
xmlhttp.open("GET",url,true);
xmlhttp.onreadystatechange=getcodevalue; //指定响应的函数
xmlhttp.send(null); //发送请求
}
}
function hidexm()
{
document.getElementById('xmform').style.display='none';
}
作者: zhagli535242428 发布时间: 2011-03-30
JScript code
function getxmlhttprequest(){ var XMLHttpReq;//局部变量 if(window.XMLHttpRequest){ //Mozilla XMLHttpReq=new XMLHttpRequest(); } else if(window.ActiveXObject){ try{ XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){} } } return XMLHttpReq; } function getcodevalue() { if(xmlhttp.readyState == 4) { var response = xmlhttp.responseText; response=response.replace(/\s/g, ""); if(response=='') {alert('对不起,您填写的资料有误或者刚咨询过,暂时不能提交!');document.getElementById('uname').value='',document.getElementById('phone').value='',document.getElementById('xm').value='';} else {alert('谢谢您的咨询,我们将尽快跟您电话联系!');document.getElementById('uname').value='',document.getElementById('phone').value='',document.getElementById('xm').value='';} } } //这个不能少,不然上面的函数的xmlhttp就没有定义 var xmlhttp; function addxm() { var uname,phone,xm; uname=document.getElementById("uname").value; phone=document.getElementById('phone').value; xm=document.getElementById('xm').value; if((uname=='')||(phone=='')||(xm=='')){alert('请填写完整的内容');document.getElementById('uname').focus();} else { xmlhttp = getxmlhttprequest(); if(xmlhttp == null) { alert("浏览器不支持xmlhttprequest!"); return; } var url = "/zx.php?username="+uname+"&phone="+phone+"&xm="+xm+"&j="+ Math.round(Math.random()*100)+"&add=ok&curl="+location.href; xmlhttp.open("GET",url,true); xmlhttp.onreadystatechange=getcodevalue; //指定响应的函数 xmlhttp.send(null); //发送请求 } } function hidexm() { document.getElementById('xmform').style.display='none'; }
作者: IBM_hoojo 发布时间: 2011-03-30
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28