ajax实现标签导航

田野里,高粱像喝醉了酒,频频点头;玉米正在变黄了的衣服里睡大觉;大豆也小坡了肚皮,蹦了出来;小白菜像列队的士兵整齐地排列在在菜地里。农民正忙忙碌碌地收获着一年的成果,田野里不时传出阵阵欢笑声。啊,秋天的景色真美啊!
主要函数:

<!--
functiongetObject(objectId){
if(document.getElementById&&document.getElementById(objectId)){
//W3CDOM
returndocument.getElementById(objectId);
}
elseif(document.all&&document.all(objectId)){
//MSIE4DOM
returndocument.all(objectId);
}
elseif(document.layers&&document.layers[objectId]){
//NN4DOM..note:thiswon'tfindnestedlayers
returndocument.layers[objectId];
}
else{
returnfalse;
}
} varresponsecont;
varxmlHttp;
varrequestType;
varnewsstring; functionCreateXMLHttpRequest(){
//InitializeMozillaXMLHttpRequestobject
if(window.XMLHttpRequest){
xmlHttp=newXMLHttpRequest();
}
//InitializeforIE/WindowsActiveXversion
elseif(window.ActiveXObject){
try{
xmlHttp=newActiveXObject("Msxml2.XMLHTTP.3.0");
}
catch(e){
try{
xmlHttp=newActiveXObject("Microsoft.XMLHTTP");
}
catch(e){newsstring="<divclass='loading'>Loadingrquestcontentfail,Pleasetryitagainlatter...</div>";}
}
}
} functiongetnews(tagid,x){
varurl=tagid+'_'+x+'.htm';
varloadstatustext="<divclass='loading'><imgsrc='images/loading.gif'/>Loadingrequestcontent,pleasewait...</div>";
requestType=tagid;
CreateXMLHttpRequest(); getObject(requestType+'_cnt').innerHTML=loadstatustext;
xmlHttp.onreadystatechange=processRequestChange;
xmlHttp.open("GET",url,true);
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
} functionprocessRequestChange(){
//onlyifxmlHttpshows"complete"
if(xmlHttp.readyState==4){
//onlyhttp200toprocess
if(window.location.href.indexOf("http")==-1||xmlHttp.status==200){
newsstring=xmlHttp.responseText;
//injectcententtotab-pane
shownews(requestType,newsstring);
}
}
} functionshownews(requestType,newsstring){
//<![CDATA[
responsecont=getObject(requestType+'_cnt');
responsecont.innerHTML=newsstring;
//]]>
} functionTabNews(tagid,x){
for(vari=1;i<=7;i+=2){
if(i==x){
getObject(tagid+i).className="tabactive"+i;
if(i!=1){
getObject(tagid+(i-1)).style.display="none";
if(i!=7){
getObject(tagid+(i+1)).style.display="none";
}
}
if(i==1){
getObject(tagid+"2").style.display="none";
}
try{
getnews(tagid,i);
}
catch(e){
alert(e);
}
}
else
{
getObject(tagid+i).className="";
if(i!=7){
getObject(tagid+(i+1)).style.display="block";
}
}
}
}
//-->

调用方法:
<listyle="cursor:pointer"id="tab3"onclick="TabNews('tab',3)">最新折扣信息</li>

本文ajax实现标签导航到此结束。要诚恳,要坦然,要慷慨,要宽容,要有平常心。小编再次感谢大家对我们的支持!

您可能有感兴趣的文章
实现AJAX异步调用和局部刷新的基本步骤

Ajax实现上传图像功能的示例详解

Ajax校验用户名是否存在的方法

AJAX请求数据及实现跨域的三种方法详解

ajax接口文档url路径的简写实例