Code
var xhr=false;
function createXhr(){ //创建xhr
if(window.XMLHttpRequest){
xhr=new XMLHttpRequest();
if(xhr.overrideMimeType){
xhr.overrideMimeType("text/xml");
}
}else if(window.ActiveXObject){
var versions=["MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
for(var i=0; i<versions.length; i++){
try{
xhr=new ActiveXObject(versions[i]);
break;
}catch (e){
//Do nothing
}
}
}
if(!xhr){
alert ("没有创建成功");
return;
}
return xhr;
//End of createXhr;
}
function gid(id){
return document.getElementById(id);
}
var btn=gid("btn");
var clr=gid("clr");
btn.onclick=getul;
clr.onclick=clear;
function getul(){
createXhr();
var url="http://cms.titan24.com/focus/kikx/ul.html";
xhr.open("GET",url,true);
xhr.onreadystatechange=fillbox;
xhr.send(null);
//alert("d");
}
function fillbox(){
if(xhr.readyState==4 && xhr.status==200){
var box=gid("box");
var tmp=xhr.responseText;
box.innerHTML=tmp;
}
}
function clear(){
var box=gid("box");
box.innerHTML="";
}
http://nba.titan24.com/focus/kikx/xhrtest.html
var xhr=false;
function createXhr(){ //创建xhr
if(window.XMLHttpRequest){
xhr=new XMLHttpRequest();
if(xhr.overrideMimeType){
xhr.overrideMimeType("text/xml");
}
}else if(window.ActiveXObject){
var versions=["MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
for(var i=0; i<versions.length; i++){
try{
xhr=new ActiveXObject(versions[i]);
break;
}catch (e){
//Do nothing
}
}
}
if(!xhr){
alert ("没有创建成功");
return;
}
return xhr;
//End of createXhr;
}
function gid(id){
return document.getElementById(id);
}
var btn=gid("btn");
var clr=gid("clr");
btn.onclick=getul;
clr.onclick=clear;
function getul(){
createXhr();
var url="http://cms.titan24.com/focus/kikx/ul.html";
xhr.open("GET",url,true);
xhr.onreadystatechange=fillbox;
xhr.send(null);
//alert("d");
}
function fillbox(){
if(xhr.readyState==4 && xhr.status==200){
var box=gid("box");
var tmp=xhr.responseText;
box.innerHTML=tmp;
}
}
function clear(){
var box=gid("box");
box.innerHTML="";
}