控制加载顺序的HTML网站使用PHP [英] Control Loading Order of HTML Site with PHP

查看:122
本文介绍了控制加载顺序的HTML网站使用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个3列的表格,其中中间一列将包含一个潜在的大量PHP脚本生成的数据。

I have a 3-column table, the middle column of which will contain a potentially large amount of data generated by a PHP script.

我有一个有限的时间来运行我的脚本,使显示的数据量是可变的。如果(如发生大部分的时间),不是所有的数据加载,那么脚本,然后才会生成表的页面与部分加载的数据的第3列和暂停出现格式不正确(如一个2列的表格,失踪右列)。

I have a limited amount of time to run my script so the amount of data shown is variable. If (as occurs most of the time) not all of the data loads, then the script is halted before it generates the 3rd column of the table and the page with the partially loaded data appears incorrectly formatted (as a 2-column table, missing the right column).

我想要做的是有这样的数据加载一旦网页的其余部分完成并放置在表的中间列在加载发生,所以该格式是正确的而不管有多少数据被装入。

What I would like to do is have this data loading occur once the rest of the page is finished and placed in the middle column of the table as it loads, so the formatting is correct regardless of how much data is loaded.

我怎么可以这样使用Ajax(是不够具体,吉兹)?

How can I do this using Ajax (is that specific enough, geez)?

推荐答案

最简单的方法可能是加载使用AJAX和jQuery数据。

The easiest way might be to load data using ajax and jQuery.

<table class="my-data-table">
    <tr>
        <td class="col-1"></td>
        <td class="col-2"></td>
        <td class="col-3"></td>
    </tr>
</table>
<script>
$.get( "/path_to_table_data.php", function on_table_data_load( data ) {
    $( ".my-data-table .col-3" ).html( data );
});
</script>

这篇关于控制加载顺序的HTML网站使用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆