AJAX jQuery tab选项卡
加载的是存在的页面,可以根据需要加载参数
XML/HTML Code
- <ulid="navigation">
- li><ahref="#page1">asp</a></li>
- ahref="#page2">PHP</li>
- ahref="#page3">html</ahref="#page4">js</imgid="loading"src="img/ajax_load.gif"alt="loading"/></</ul>
- divclass="clear"></div>
- divid="pageContent">
- page1</div>
- div>
JavaScript Code
- vardefault_content="";
- $(document).ready(function(){
- checkURL();
- $('ullia').click(function(e){
- checkURL(this.hash);
- });
- //fillinginthedefaultcontent
- default_content=$('#pageContent').html();
- setInterval("checkURL()",250);
- varlasturl="";
- functioncheckURL(hash)
- {
- if(!hash)hash=window.location.hash;
- if(hash!=lasturl)
- lasturl=hash;
- //FIX-ifwe'veusedthehistorybuttonstoreturntothehomepage,
- //fillthepageContentwiththedefault_content
- if(hash=="")
- $('#pageContent').html(default_content);
- else
- loadPage(hash);
- }
- }
- functionloadPage(url)
- {
- url=url.replace('#page','');
- $('#loading').css('visibility','visible');
- $.ajax({
- type:"POST",
- url:"load_page.PHP",
- data:'page='+url,0);">dataType:"html",0);">success:function(msg){
- if(parseInt(msg)!=0)
- {
- $('#pageContent').html(msg);
- hidden');
- }
- }
- }