php - Can someone explain to me how this appending a table with ajax works? -
so using mottie's fork of tablesorter plug in , has been working me. have couple pages have large records of data need deal with. assume best way of going using ajax fill table. there example in documentation not know javascript or ajax not sure how working.
http://mottie.github.io/tablesorter/docs/example-ajax.html
a couple specific questions be.
what code on assets/ajax-content.html like? piece wanted know about. how getting records , sending them back.
i don't understand how
("#ajax-append").click(function() is working. how receiving 'html' parameter on line
$.get("assets/ajax-content.html", function(html) { any appreciated. thanks
from examples, can determine it's returning html. back-end script want same. example page, tbody contains following:
<tr> <td>bruce</td> <td>evans</td> <td>22</td> <td>$13.19</td> <td>11%</td> <td>jan 18, 2007 9:12 am</td> </tr> so when click link (<a href="#" id="ajax-append">append new table data</a>) in example, append more table rows table body. can hope wants more of same. example be:
<?php // connect db // run query // recordset // output recordset in table row format while($row = $sql->fetch_assoc($results)){ echo "<tr>\r\n"; echo "\t<td>{$row['fname']}</td>\r\n"; echo "\t<td>{$row['lname']}</td>\r\n"; echo "\t<td>{$row['age']}</td>\r\n"; echo "\t<td>{$row['total']}</td>\r\n"; echo "\t<td>{$row['discount']}</td>\r\n"; echo "\t<td>{$row['date']}</td>\r\n"; echo "</tr>\r\n"; } $sql->close(); ?>
Comments
Post a Comment