加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

AJAX jQuery tab选项卡

发布时间:2020-12-16 00:50:28 所属栏目:百科 来源:网络整理
导读:AJAX jQuery tab选项卡 加载的是存在的页面,可以根据需要加载参数 演示 XML/HTML Code ul id = "navigation" li a href = "#page1" asp / a / li a href = "#page2" php / li a href = "#page3" html / a href = "#page4" js / img id = "loading" src = "i

AJAX jQuery tab选项卡

加载的是存在的页面,可以根据需要加载参数

演示

XML/HTML Code
  1. <ulid="navigation">
  2. li><ahref="#page1">asp</a></li>
  3. ahref="#page2">php</li>
  4. ahref="#page3">html</ahref="#page4">js</imgid="loading"src="img/ajax_load.gif"alt="loading"/></</ul>
  5. divclass="clear"></div>
  6. divid="pageContent">
  7. page1</div>
  8. div>
JavaScript Code
    vardefault_content="";
  1. $(document).ready(function(){
  2. checkURL();
  3. $('ullia').click(function(e){
  4. checkURL(this.hash);
  5. });
  6. //fillinginthedefaultcontent
  7. default_content=$('#pageContent').html();
  8. setInterval("checkURL()",250);
  9. varlasturl="";
  10. functioncheckURL(hash)
  11. {
  12. if(!hash)hash=window.location.hash;
  13. if(hash!=lasturl)
  14. lasturl=hash;
  15. //FIX-ifwe'veusedthehistorybuttonstoreturntothehomepage,
  16. //fillthepageContentwiththedefault_content
  17. if(hash=="")
  18. $('#pageContent').html(default_content);
  19. else
  20. loadPage(hash);
  21. }
  22. }
  23. functionloadPage(url)
  24. {
  25. url=url.replace('#page','');
  26. $('#loading').css('visibility','visible');
  27. $.ajax({
  28. type:"POST",
  29. url:"load_page.php",
  30. data:'page='+url,0);">dataType:"html",0);">success:function(msg){
  31. if(parseInt(msg)!=0)
  32. {
  33. $('#pageContent').html(msg);
  34. hidden');
  35. }
  36. }
  37. }

load_page.php

PHP Code
    <?php
  1. if(!$_POST['page'])die("0");
  2. $page=(int)$_POST['page'];
  3. if(file_exists('pages/page_'.$page.'.html'))
  4. echofile_get_contents('pages/page_'.$page.'.html');
  5. elseecho'Thereisnosuchpage!';
  6. ?>


原文地址:http://www.freejs.net/article_tabbiaoqian_71.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读