ajax 之XMLHttpRequest两种创建方法
2009-02-06 08:41
309 查看
/**//* 创建XMLHttpRequest的第一种方法
try{
searchReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e){
try{
searchReq = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e){
try{
searchReq = new XMLHttpRequest();
}
catch(e)
{}
}
}
*/
//创建XMLHttpRequest的第二种方法
function createReq(){
var httpReq;
if(window.XMLHttpRequest){
httpReq = new XMLHttpRequest();
if(httpReq.overrideMimeType){
httpReq.overrideMimeType('text/xml');
}
}
else if(window.ActiveXObject){
try{
httpReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e){
try{
httpReq = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e){
}
}
}
return httpReq;
}
try{
searchReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e){
try{
searchReq = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e){
try{
searchReq = new XMLHttpRequest();
}
catch(e)
{}
}
}
*/
//创建XMLHttpRequest的第二种方法
function createReq(){
var httpReq;
if(window.XMLHttpRequest){
httpReq = new XMLHttpRequest();
if(httpReq.overrideMimeType){
httpReq.overrideMimeType('text/xml');
}
}
else if(window.ActiveXObject){
try{
httpReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e){
try{
httpReq = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e){
}
}
}
return httpReq;
}
相关文章推荐
- Ajax创建XMLHttpRequest对象通用方法
- js原生创建封装ajax的方法,附XMLHttpRequest状态码
- JS创建Ajax的XMLHttpRequest对象的通用方法
- Ajax中封装创建XMLHttpRequest对象的方法
- 如何用ajax来创建一个XMLHttpRequest对象
- 原始ajax通过xmlHttpRequest对象的send()方法提交数据--Get方式和Post方式
- XMLHttpRequest Ajax 实例简介 (用此方法可实现JS与SQL连接)
- Ajax核心XMLHttpRequest对象、(发送请求、接收)方法和属性介绍、AJAX开发框架、数据格式提要(XML、JSON、HTML)
- Ajax 中 XMLHttpRequest对象的方法与属性
- AJAX - 创建 XMLHttpRequest 对象
- AJAX - 创建XMLHttpRequest 对象
- NET中用JavaScript来创建XMLHttpRequest 的Ajax开发介绍
- 创建XMLHttpRequest对象并向服务器发送请求的方法
- AJAX中同时发送多个请求XMLHttpRequest对象处理方法
- AJAX(XMLHttpRequest)进行跨域请求方法详解(二)
- AJAX(XMLHttpRequest)进行跨域请求方法详解(一) 推荐
- 支持IE7的XmlHttpRequest创建方法
- 封装支持FireFox与IE创建XMLHttpRequest方法
- Ajax的XMLHttpRequest对象的属性和方法
- AJAX概念介绍:2.2 XMLHttpRequest对象的创建、请求、响应