// JavaScript Document
function GetResult(url){
var showmov = null;
if(window.XMLHttpRequest){ //IE7, Mozilla ,Firefox 等浏览器内置该对象
showmov = new XMLHttpRequest();
}else if(window.ActiveXObject){ //IE6、IE5
try{ showmov = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){ ; }
if( showmov == null) try { showmov = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){; }
}
showmov.open("post",url,false);
showmov.send();
var strResult = showmov.responseText;
showmov = null
return strResult;
}
function GetResult(url){
var showmov = null;
if(window.XMLHttpRequest){ //IE7, Mozilla ,Firefox 等浏览器内置该对象
showmov = new XMLHttpRequest();
}else if(window.ActiveXObject){ //IE6、IE5
try{ showmov = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){ ; }
if( showmov == null) try { showmov = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){; }
}
showmov.open("post",url,false);
showmov.send();
var strResult = showmov.responseText;
showmov = null
return strResult;
}
本文介绍了一个使用纯 JavaScript 实现 AJAX 请求的方法。通过判断浏览器类型选择不同的 XMLHttpRequest 对象创建方式,并采用 POST 方法发送请求,获取服务器响应。

被折叠的 条评论
为什么被折叠?



