重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章主要讲解了“ajax.js里面如何根据ID显示内容”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“ajax.js里面如何根据ID显示内容”吧!
“专业、务实、高效、创新、把客户的事当成自己的事”是我们每一个人一直以来坚持追求的企业文化。 创新互联是您可以信赖的网站建设服务商、专业的互联网服务提供商! 专注于成都做网站、网站建设、软件开发、设计服务业务。我们始终坚持以客户需求为导向,结合用户体验与视觉传达,提供有针对性的项目解决方案,提供专业性的建议,创新互联建站将不断地超越自我,追逐市场,引领市场!
ajax.js里面有内容显示效果,根据ID
代码如下:
var http_request = false;
var success=false;
var ShowAllListFlag=1;
var DisplayArticle=true;
function makeRequest(url,cateID) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
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;
}
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
success=true;
} else {
alert('There was a problem with the request.');
}
}
}
function setCatlog(ID,Order,LeftNumber) {
var cateID=document.getElementById('Cate'+ID);
setdisplay(cateID);
if (cateID.style.display=="")
{
var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&Order="+Order+"&LeftNumber="+LeftNumber+"&r="+Math.random();
makeRequest(url2,cateID);
}
else
{
var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&RemoveID=1&r="+Math.random();
makeRequest(url2,cateID);
}
}
function setArticleList(EncodeURL,ArticleID) {
if (DisplayArticle==true)
{
try { var objArticleIDtop = document.getElementById('top'+ArticleID);
var objArticleIDbottom = 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")
{
var url2="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
{
}
}
function DisplayContent(ArticleID) {
if (DisplayArticle==true)
{
try { var objArticleIDtop = document.getElementById('top'+ArticleID);
var objArticleIDbottom = 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
{
}
}
function setdisplay(cateID) {
if (cateID.style.display=="none")
{
cateID.style.display="";
cateID.innerHTML="Loading..."
}
else
{
cateID.style.display="none";
}
}
function setdisplay2(cateID) {
if (ShowAllListFlag==1)
{
cateID.style.display="";
cateID.innerHTML="Loading..."
}
else
{
cateID.style.display="none";
}
}
function ShowAllList(Order,LeftNumber,TagName) {
var obj = document.getElementsByTagName(TagName)
for (a=0;a
if (obj[a].className=="SiteList")
{
obj2=obj[a].id;
var ID=obj2.replace("Cate","");
var cateID=document.getElementById(obj2);
setdisplay2(cateID);
if (cateID.style.display=="")
{
var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&Order="+Order+"&LeftNumber="+LeftNumber+"&r="+Math.random();
makeRequest(url2,cateID);
}
else
{
var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&RemoveID=1&r="+Math.random();
makeRequest(url2,cateID);
}
}
}
if (ShowAllListFlag==1)
{
ShowAllListFlag=2;
}
else
{
ShowAllListFlag=1;
}
}
function ExpandListBySession(Str,Order,LeftNumber) {
try {
var ExpandList=Str.split("|");
for (b=0;b
setCatlog(ExpandList[b],Order,LeftNumber)
}
} catch (e) {}
}
感谢各位的阅读,以上就是“ajax.js里面如何根据ID显示内容”的内容了,经过本文的学习后,相信大家对ajax.js里面如何根据ID显示内容这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!