weixin_33698823 2013-10-01 09:48 采纳率: 0%
浏览 14

使用AJAX加载MYsql查询

My website take long respond to load,it is create on Cake PHP.

In my site there is 7 MySql query, when i load the page,7 querys run so it take 5 seconds to 18 seconds and then sever send response in HTML format to browser, and then full page show with in 0.5s. i mean suddenly full page show. ,

my page have five section like header, menu bar, content, side bar and footer,

is this possible that every section load one by one, its look like, when new visitor come, so page response is like that, first head show, then menu, then context, then side bar and at the end footer show.

My domain speed is very fast, my admin panel open in 1 sec, but pages are take long time, so thats why i want to do this, My admin panel is fast but pages take long time to send First Byte.

here is simple code,

<body>
<div class="container">

<?php include("head.php"); ?>

<?php include("menu.php"); ?>

<?php include("content.php"); ?>

<?php include("side_bar.php"); ?>

<?php include("footer.php"); ?>
</div>
</body>

how can i do this, first head.php page and its Mysql query run and server response show in browser

then second part menu.php page and its Mysql query run and server response show in browser,

all other pages that i include in <body> run one by one and result show on browser

so with this decnique visitor wait less,

how can i use AJAX here or and other technique?

Please guide me, may be this technique decrease page load time and First byte response.

thank you

  • 写回答

1条回答 默认 最新

  • weixin_33691700 2013-10-01 10:57
    关注

    If I understand your query correctly, could you not place the includes inside if statements based on the result from the previous include?

    For example if your head.php runs a mysql query called $head_result, you could have:

    if (count($head_result) > 0)
    {
        include("menu.php");
    }
    

    Or something similar

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行