科讯商业版中用到的科讯商业版中用到的ajax空间与分页函数空间与分页函数
科讯sql商业版中用到的ajax空间与分页函数,他们的js代码学习是非常不错的
//ajax 控件
function PageAjax(){
var xhrObj=null;
if(window.XMLHttpRequest)
{
xhrObj=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
try{
xhrObj=new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch(e1)
{
try{
xhrObj=new ActiveXObject(“MSXML2.XMLHTTP”);
}
catch(e2){
try{
xhrObj=new ActiveXObject(“MSXML3.XMLHTTP”);
}
catch(e3){
alert(“创建Ajax失败:”+e3)
}
}
}
}
else
{
alert(“未能识别的浏览器”);
}
return xhrObj;
}
function Page(curPage,labelid,classid,installdir,url,refreshtype,specialid)
{
this.labelid=labelid;
this.classid=classid;
this.url=url;
if (labelid.substring(0,5)==”{SQL_”)
{
var slabelid=labelid.split(‘(‘)[0];
slabelid=slabelid.replace(“{“,””);
this.c_obj=”c_”+slabelid;
this.p_obj=”p_”+slabelid;
}
else
{
this.c_obj=”c_”+labelid;
this.p_obj=”p_”+labelid;
}
this.installdir=installdir;
this.refreshtype=refreshtype;
this.specialid=specialid;
this.page=curPage;
loadData(1);
}
function loadData(p)
{ this.page=p;
var xhr=new PageAjax();
xhr.open(“get”,installdir+url+”?
labelid=”+escape(labelid)+”&classid=”+classid+”&refreshtype=”+refreshtype+”&specialid=” +specialid+”&curpage=”+p,true);
xhr.onreadystatechange=function (){
if(xhr.readyState==1)
{
if (p==1)