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
       }
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂