0

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

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.

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

1 Answers1

1

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>
Chris Gunawardena
  • 6,246
  • 1
  • 29
  • 45