ajax.js里面有内容显示效果,根据ID_AJAX相关教程-查字典教程网
ajax.js里面有内容显示效果,根据ID
ajax.js里面有内容显示效果,根据ID
发布时间:2016-12-29 来源:查字典编辑
摘要:ajax.js里面有内容显示效果,根据ID复制代码代码如下:varhttp_request=false;varsuccess=false;v...

ajax.js里面有内容显示效果,根据ID

复制代码 代码如下:

varhttp_request=false;

varsuccess=false;

varShowAllListFlag=1;

varDisplayArticle=true;

functionmakeRequest(url,cateID){

http_request=false;

if(window.XMLHttpRequest){//Mozilla,Safari,...

http_request=newXMLHttpRequest();

if(http_request.overrideMimeType){

http_request.overrideMimeType('text/xml');

}

}elseif(window.ActiveXObject){//IE

try{

http_request=newActiveXObject("Msxml2.XMLHTTP");

}catch(e){

try{

http_request=newActiveXObject("Microsoft.XMLHTTP");

}catch(e){}

}

}

if(!http_request){

alert('Givingup:(CannotcreateanXMLHTTPinstance');

returnfalse;

}

http_request.onreadystatechange=alertContents;

http_request.open('GET',url,false);

http_request.send(null);

if(success==true)

{

try{

cateID.innerHTML=http_request.responseText;

}catch(e){}

success==false;

}

}

functionalertContents(){

if(http_request.readyState==4){

if(http_request.status==200){

success=true;

}else{

alert('Therewasaproblemwiththerequest.');

}

}

}

functionsetCatlog(ID,Order,LeftNumber){

varcateID=document.getElementById('Cate'+ID);

setdisplay(cateID);

if(cateID.style.display=="")

{

varurl2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&Order="+Order+"&LeftNumber="+LeftNumber+"&r="+Math.random();

makeRequest(url2,cateID);

}

else

{

varurl2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&RemoveID=1&r="+Math.random();

makeRequest(url2,cateID);

}

}

functionsetArticleList(EncodeURL,ArticleID){

if(DisplayArticle==true)

{

try{varobjArticleIDtop=document.getElementById('top'+ArticleID);

varobjArticleIDbottom=document.getElementById('bottom'+ArticleID);

if(objArticleIDtop)

{

if(objArticleIDtop.style.display=="none")

{

objArticleIDtop.style.display="";

}

else

{

objArticleIDtop.style.display="none";

}

}

if(objArticleIDbottom)

{

if(objArticleIDbottom.style.display=="none")

{

varurl2="INCLUDE/GetArticleFunction.asp?LinkStr="+EncodeURL+"&r="+Math.random();

makeRequest(url2,objArticleIDbottom);

objArticleIDbottom.style.display="";

}

else

{

objArticleIDbottom.style.display="none";

}

}

}catch(e){alert(e.description);}

}

else

{

}

}

functionDisplayContent(ArticleID){

if(DisplayArticle==true)

{

try{varobjArticleIDtop=document.getElementById('top'+ArticleID);

varobjArticleIDbottom=document.getElementById('bottom'+ArticleID);

if(objArticleIDtop)

{

if(objArticleIDtop.style.display=="none")

{

objArticleIDtop.style.display="";

}

else

{

objArticleIDtop.style.display="none";

}

}

if(objArticleIDbottom)

{

if(objArticleIDbottom.style.display=="none")

{

objArticleIDbottom.style.display="";

}

else

{

objArticleIDbottom.style.display="none";

}

}

}catch(e){alert(e.description);}

}

else

{

}

}

functionsetdisplay(cateID){

if(cateID.style.display=="none")

{

cateID.style.display="";

cateID.innerHTML="Loading..."

}

else

{

cateID.style.display="none";

}

}

functionsetdisplay2(cateID){

if(ShowAllListFlag==1)

{

cateID.style.display="";

cateID.innerHTML="Loading..."

}

else

{

cateID.style.display="none";

}

}

functionShowAllList(Order,LeftNumber,TagName){

varobj=document.getElementsByTagName(TagName)

for(a=0;a<obj.length;a++)

{

if(obj[a].className=="SiteList")

{

obj2=obj[a].id;

varID=obj2.replace("Cate","");

varcateID=document.getElementById(obj2);

setdisplay2(cateID);

if(cateID.style.display=="")

{

varurl2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&Order="+Order+"&LeftNumber="+LeftNumber+"&r="+Math.random();

makeRequest(url2,cateID);

}

else

{

varurl2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&RemoveID=1&r="+Math.random();

makeRequest(url2,cateID);

}

}

}

if(ShowAllListFlag==1)

{

ShowAllListFlag=2;

}

else

{

ShowAllListFlag=1;

}

}

functionExpandListBySession(Str,Order,LeftNumber){

try{

varExpandList=Str.split("|");

for(b=0;b<ExpandList.length-1;b++)

{

setCatlog(ExpandList[b],Order,LeftNumber)

}

}catch(e){}

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新AJAX相关学习
    热门AJAX相关学习
    编程开发子分类