douganggu4392 2014-05-15 10:25
浏览 87
已采纳

在jquery ui tabs中加载不同的页面很慢,有时会崩溃

My boss wanted different process (which were originally individual pages) to show up on tabs

anyway I'm using the jquery ui tabs

http://jqueryui.com/tabs/

my code

jquery

    <script type="text/javascript">
$(document).ready(function()
{ 
$("#tabs-1").load("transaction.php");
$("#tabs-2").load("book.php");
$("#tabs-3").load("schedule.php");
});
</script>

html

<ul>
<li><a href="#tabs-1">Transaction</a></li>
<li><a href="#tabs-2">Book</a></li>
<li><a href="#tabs-3">Schedule</a></li>
</ul>
<div id="tabs-1">
</div>
<div id="tabs-2">
</div>
<div id="tabs-3">

each page pulls up data in mysql database the problem is, book.php has lots of data so loading it is slow and sometimes the browser crashes

is this implementation possible or should I explain this that using tabs is not recommended, this should be showed using individual pages?

  • 写回答

1条回答 默认 最新

  • dshqd84261 2014-05-15 10:30
    关注

    what you could do is get the book.php to only load when tab 2 is clicked.

    $("#tabs-2").click(function(){
        $("#tabs-2").load("book.php");
    });
    

    this should help to stop it crashing straight away. if it doesn't help you will need to optimise you query.

    you could also try using ajax.

    put this in you document load and hopefully it should load the contents of book.php into the tab.

      $.get( "book.php", function(book) {
        $("#tabs-2").html(book);
      });
    

    Jquery Sample

    $.ajax({
       type: "POST",
       url: "page_url",
       data: $("#advserc").serialize() + "&pagenum=" + page, // i sent the page through with it
      beforeSend:function(){  // this unhides a div with gif loading image in it.
            //show gif here, eg:
            $("#loading").show();
    
        },
        complete:function(){
            //hide gif here, eg:
            $("#loading").hide(); // this hides the div
        },
       success: function(data){
          $("#content-container").html(data); // here i fill the div with the dat from the php page
       }
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题