function Ajax(){
this.httpXML=false;
this.init();
}
Ajax.prototype.init=function(){
if(window.XMLHttpRequest){
this.httpXML=new XMLHttpRequest();
if (this.httpXML.overrideMimeType){
this.httpXML.overrideMimeType("text/xml");
}
}else if(window.ActiveXObject){
try{this.httpXML = new ActiveXObject("Msxml2.XMLHTTP");}catch (e){
try{this.httpXML = new ActiveXObject("Microsoft.XMLHTTP");}catch (e){}
}
}
if(!this.httpXML){
window.alert("can't create XMLHttpRequest object");
return null;
}
}
Ajax.prototype.send=function(_method,_url,_data,_callback){
this.httpXML.onreadystatechange=function(){
if(this.readyState==4&&this.status==200){
_callback.call(this,this.responseText);
}
}
if (_method.toLowerCase() == "get"){
//if(navigator.userAgent.indexOf("MSIE")<=0){
// netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
//}
this.httpXML.open(_method, _url, true);
this.httpXML.send(null);
}else if (_method.toLowerCase() == "post"){
this.httpXML.open(_method, _url, true);
this.httpXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
this.httpXML.send(_data);
}
}
Ajax.prototype.callback=function(){
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>完美兼容IE、FF、Opera浏览器</title>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
function send(){
ajax=new Ajax();
ajax.send("get","listener/Hajax.ashx","post测试请求",ddd);
}
function ddd(data){
alert(data);
}
</script>
</head>
<body>
<button onclick="send()">测试</button>
</body>
</html>
分享到:
相关推荐
ajax简易模型 兼容多个浏览器(ff ie ...) get post请求
CSS完美兼容IE6IE7FF的通用方法
兼容IE FF 省级三级联动 兼容IE FF 省级三级联动 兼容IE FF 省级三级联动 兼容IE FF 省级三级联动
JavaScript 瀑布流 吸顶 兼容IE FF Chrome
div css完美兼容IE6,IE7,FF的通用方法说明。
CSS完美兼容IE6/IE7/FF的通用方法 一、CSS HACK 以下两种方法几乎能解决现今所有HACK.
NULL 博文链接:https://smallq.iteye.com/blog/359112
兼容ie,FF,chrome,opera的弹出层居中js。
ie6 ie7 ff浏览器兼容 border:2px solid #00f; /*IE、ff的属性*/ border:2px solid #090\9; /* IE6/7/8的属性 */ border:2px solid #F90\0; /* IE8支持 */ *border:2px solid #F00; /* IE6、7支持 */ _border:2...
兼容IE,火狐的日历控件,个人感觉不错,支持多国语言,可惜没中文,要用中文的可以自己该中文
兼容IE FF复制粘贴 在IE6、IE7、IE8、FireFox中均测试通过
jsencrypt 兼容IE8,Chrome,FF,包括exports.default,Object.defineProperty不兼容问题处理等。
一个图片居中的CSS示例,兼容IE6,7,8和FF,opera,safari
Js 实现的幻灯片效果 兼容 IE FF
JS 无限极菜单 兼容IE FF 可更改图标
光标处插入,兼容IE系列,FF等,适用于编辑器,浏览插入表情 //网上没有真正兼容IE和FF的代码,只是做到一种; //代码为本人对IE和FF光标插入支持整合修改;
如qsort 等函数需要函数指针才能回调 用此函数库可以将成员函数指针转为普通函数指针 测试代码如下 #include #include #include #include #include #include using cmpfunc = int(__cdecl*)(const void*, ...