asp实现dig功能的js代码
asp实现dig功能的js代码
发布时间:2016-12-29 来源:查字典编辑
摘要://ajax控件functionDiggAjax(){varxhrObj=null;if(window.XMLHttpRequest){xh...

//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-www-form-urlencoded");

}

loader.onreadystatechange=function(){

eval(fun+'()');

}

loader.send(request);

}

functioncallbacks()

{

if(loader.readyState==4)

{

vars=loader.responseText;

switch(s)

{

case"err":

alert('diggerror!');

break;

case"over":

alert('你已推荐过了!');

break;

case"nologin":

alert('您还没有登录,不能推荐!');

break;

default:

varsarr=s.split('|');

eval("document.all.s"+sarr[0]).innerHTML=sarr[1];

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==2||xhr.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);

}

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ASP教程学习
热门ASP教程学习
编程开发子分类