日期:2014-05-16  浏览次数:20520 次

简单的ajax

<!--

var http_request=false;
var meRequest=false;
var ID="";
function createXMLHttpRequest(){
?if(window.XMLHttpRequest) {
??http_request = new XMLHttpRequest();
??meRequest = new XMLHttpRequest();
?}
?else if (window.ActiveXObject) {
??try{
???http_request = new ActiveXObject("Msxml2.XMLHTTP");
???meRequest = new ActiveXObject("Msxml2.XMLHTTP");
??}
??catch(e){
????try{
?????http_request = new ActiveXObject("Microsoft.XMLHTTP");
?????meRequest = new ActiveXObject("Microsoft.XMLHTTP");
????}catch(e){}
??}
????
?}
??
}
?
function sendmeRequest(url,id) {
?ID=id;
?createXMLHttpRequest();
?meRequest.onreadystatechange = processRequest;
?meRequest.open("GET", url, true);
?meRequest.send(null);
}
// 处理返回信息的函数
function processRequest() {
?if (meRequest.readyState == 4) { // 判断对象状态
??if (meRequest.status == 200) { // 信息已经成功返回,开始处理信息
???var content=document.getElementById(ID);
???content.innerHTML=meRequest.responseText;
???//document.write(content.innerHTML);
??}
??????? else alert("您所请求的页面有异常。");//页面不正常
?}
}
function show(url,id){
?sendmeRequest(url,id);
?document.getElementById(id).style.display='block';
}
function hide(id){
?var win=document.getElementById(id);
?win.style.display='none';
?
}
-->

?