📄 contentreader.js
字号:
var contentReader=new Object();
contentReader=function(url,onload,onerror){
this.req=null;
this.onload=onload;
this.onerror=(onerror) ? onerror : this.defaultError;
this.loadXMLDoc(url);
}
contentReader.prototype.loadXMLDoc=function(url){
if (window.XMLHttpRequest){
this.req=new XMLHttpRequest();
} else if (window.ActiveXObject){
this.req=new ActiveXObject("Microsoft.XMLHTTP");
}
if (this.req){
try{
var loader=this;
this.req.onreadystatechange=function(){
contentReader.onReadyState.call(loader);
}
this.req.open('GET',url,true);
this.req.send(null);
}catch (err){
this.onerror.call(this);
}
}
}
contentReader.onReadyState=function(){
var req=this.req;
var ready=req.readyState;
if (ready==4){
var httpStatus=req.status;
if (httpStatus==200 || httpStatus==0){
this.onload.call(this);
}else{
this.onerror.call(this);
}
}
}
contentReader.prototype.defaultError=function(){
alert("error fetching data!"
+" readyState:"+this.req.readyState
+" status: "+this.req.status
+" headers: "+this.req.getAllResponseHeaders());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -