asp实现dig功能的js代码

2018-09-06 12:59

阅读:446

  //ajax控件
functionDiggAjax(){
varxhrObj=null;
if(window.XMLHttpRequest){
xhrObj=newXMLHttpRequest();
}
elseif(window.ActiveXObject){
try{
xhrObj=newActiveXObject(Microsoft.XMLHTTP);
}
catch(e1)
{
try{
xhrObj=newActiveXObject(MSXML2.XMLHTTP);
}
catch(e2){
try{
xhrObj=newActiveXObject(MSXML3.XMLHTTP);
}
catch(e3){
alert(创建Ajax失败:+e3)
}
}
}
}
else
{
alert(未能识别的浏览器);
}
returnxhrObj;
}
varloader=newDiggAjax;
functionajaxLoadPage(url,request,method,fun)
{
method=method.toUpperCase();
if(method==GET)
{
urls=url.split(?);
if(urls[1]==typeofurls[1]==undefined)
{
url=urls[0]+?+request;
}
else
{
url=urls[0]+?+urls[1]+&+request;
}

request=null;
}
loader.open(method,url,true);
if(method==POST)
{
loader.setRequestHeader(Content-Type,application/x-
}
loader.onreadystatechange=function(){
eval(fun+());
}
loader.send(request);
}
functioncallbacks()
{
if(loader.readyState==4)
{
vars=loader.responseText;
switch(s)
{
caseerr:
alert(diggerror!);
break;
caseover:
alert(你已推荐过了!);
break;
casenologin:
alert(您还没有登录,不能推荐!);
break;
default:
varsarr=s.split();
eval(document.all.d+sarr[0]).innerHTML=Thanks;

}

}
}


//Digg
functiondigg(channelid,infoid,installdir)
{
ajaxLoadPage(installdir+plus/digg.asp,action=hits&ChannelID=+channelid+&infoid=+infoid,post,callbacks);

}
functionshow_digg(channelid,infoid,installdir)
{
varxhr=newDiggAjax();
xhr.open(get,installdir+plus/digg.asp?channelid=+channelid+&infoid=+infoid+&action=show,true);
xhr.onreadystatechange=function(){
if(xhr.readyState==1)
{
eval(document.all.s+infoid).innerHTML=<imgsrc=+installdir+images/loading.gif>;
}
elseif(xhr.readyState==2xhr.readyState==3)
{
eval(document.all.s+infoid).innerHTML=<imgsrc=+installdir+images/loading.gif>;
}
elseif(xhr.readyState==4)
{
if(xhr.status==200)
{
varr=xhr.responseText
varrarr=r.split();
eval(document.all.s+infoid).innerHTML=rarr[1];
}
}
}
xhr.send(null);
}


评论


亲,登录后才可以留言!