ajax.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
  6. <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
  7. <title>TableTools example - Ajax loaded data</title>
  8. <link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
  9. <link rel="stylesheet" type="text/css" href="../css/dataTables.tableTools.css">
  10. <link rel="stylesheet" type="text/css" href="../../../examples/resources/syntax/shCore.css">
  11. <link rel="stylesheet" type="text/css" href="../../../examples/resources/demo.css">
  12. <style type="text/css" class="init">
  13. </style>
  14. <script type="text/javascript" language="javascript" src="../../../media/js/jquery.js"></script>
  15. <script type="text/javascript" language="javascript" src="../../../media/js/jquery.dataTables.js"></script>
  16. <script type="text/javascript" language="javascript" src="../js/dataTables.tableTools.js"></script>
  17. <script type="text/javascript" language="javascript" src="../../../examples/resources/syntax/shCore.js"></script>
  18. <script type="text/javascript" language="javascript" src="../../../examples/resources/demo.js"></script>
  19. <script type="text/javascript" language="javascript" class="init">
  20. $(document).ready(function() {
  21. $('#example').DataTable( {
  22. dom: 'T<"clear">lfrtip',
  23. "ajax": "../../../../examples/ajax/data/objects.txt",
  24. "columns": [
  25. { "data": "name" },
  26. { "data": "position" },
  27. { "data": "office" },
  28. { "data": "extn" },
  29. { "data": "start_date" },
  30. { "data": "salary" }
  31. ],
  32. deferRender: true
  33. } );
  34. } );
  35. </script>
  36. </head>
  37. <body class="dt-example">
  38. <div class="container">
  39. <section>
  40. <h1>TableTools example <span>Ajax loaded data</span></h1>
  41. <div class="info">
  42. <p>This TableTools example shows DataTables using its ability to <a href=
  43. "//datatables.net/manual/data#Objects">Ajax load object based data</a> and operate in exactly the same
  44. manner as when the data is read directly from the document.</p>
  45. </div>
  46. <table id="example" class="display" cellspacing="0" width="100%">
  47. <thead>
  48. <tr>
  49. <th>Name</th>
  50. <th>Position</th>
  51. <th>Office</th>
  52. <th>Extn.</th>
  53. <th>Start date</th>
  54. <th>Salary</th>
  55. </tr>
  56. </thead>
  57. <tfoot>
  58. <tr>
  59. <th>Name</th>
  60. <th>Position</th>
  61. <th>Office</th>
  62. <th>Extn.</th>
  63. <th>Start date</th>
  64. <th>Salary</th>
  65. </tr>
  66. </tfoot>
  67. </table>
  68. <ul class="tabs">
  69. <li class="active">Javascript</li>
  70. <li>HTML</li>
  71. <li>CSS</li>
  72. <li>Ajax</li>
  73. <li>Server-side script</li>
  74. </ul>
  75. <div class="tabs">
  76. <div class="js">
  77. <p>The Javascript shown below is used to initialise the table shown in this
  78. example:</p><code class="multiline brush: js;">$(document).ready(function() {
  79. $('#example').DataTable( {
  80. dom: 'T&lt;&quot;clear&quot;&gt;lfrtip',
  81. &quot;ajax&quot;: &quot;../../../../examples/ajax/data/objects.txt&quot;,
  82. &quot;columns&quot;: [
  83. { &quot;data&quot;: &quot;name&quot; },
  84. { &quot;data&quot;: &quot;position&quot; },
  85. { &quot;data&quot;: &quot;office&quot; },
  86. { &quot;data&quot;: &quot;extn&quot; },
  87. { &quot;data&quot;: &quot;start_date&quot; },
  88. { &quot;data&quot;: &quot;salary&quot; }
  89. ],
  90. deferRender: true
  91. } );
  92. } );</code>
  93. <p>In addition to the above code, the following Javascript library files are loaded for use in this
  94. example:</p>
  95. <ul>
  96. <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
  97. <li><a href=
  98. "../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
  99. <li><a href="../js/dataTables.tableTools.js">../js/dataTables.tableTools.js</a></li>
  100. </ul>
  101. </div>
  102. <div class="table">
  103. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
  104. DataTables:</p>
  105. </div>
  106. <div class="css">
  107. <div>
  108. <p>This example uses a little bit of additional CSS beyond what is loaded from the library
  109. files (below), in order to correctly display the table. The additional CSS used is shown
  110. below:</p><code class="multiline brush: js;"></code>
  111. </div>
  112. <p>The following CSS library files are loaded for use in this example to provide the styling of the
  113. table:</p>
  114. <ul>
  115. <li><a href=
  116. "../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
  117. <li><a href="../css/dataTables.tableTools.css">../css/dataTables.tableTools.css</a></li>
  118. </ul>
  119. </div>
  120. <div class="ajax">
  121. <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
  122. will update automatically as any additional data is loaded.</p>
  123. </div>
  124. <div class="php">
  125. <p>The script used to perform the server-side processing for this table is shown below. Please note
  126. that this is just an example script using PHP. Server-side processing scripts can be written in any
  127. language, using <a href="//datatables.net/manual/server-side">the protocol described in the
  128. DataTables documentation</a>.</p>
  129. </div>
  130. </div>
  131. </section>
  132. </div>
  133. <section>
  134. <div class="footer">
  135. <div class="gradient"></div>
  136. <div class="liner">
  137. <h2>Other examples</h2>
  138. <div class="toc">
  139. <div class="toc-group">
  140. <h3><a href="./index.html">Examples</a></h3>
  141. <ul class="toc active">
  142. <li><a href="./simple.html">Basic initialisation</a></li>
  143. <li><a href="./plug-in.html">Plug-in button types</a></li>
  144. <li><a href="./bootstrap.html">Bootstrap styling</a></li>
  145. <li><a href="./swf_path.html">Setting the SWF path</a></li>
  146. <li><a href="./new_init.html">Initialisation with `new`</a></li>
  147. <li><a href="./defaults.html">Defaults</a></li>
  148. <li><a href="./select_single.html">Row selection - single row select</a></li>
  149. <li><a href="./select_multi.html">Row selection - multi-row select</a></li>
  150. <li><a href="./select_os.html">Row selection - operating system style</a></li>
  151. <li><a href="./select_column.html">Row selection - row selector on specific cells</a></li>
  152. <li><a href="./multiple_tables.html">Multiple tables</a></li>
  153. <li><a href="./multi_instance.html">Multiple toolbars</a></li>
  154. <li><a href="./collection.html">Button collections</a></li>
  155. <li><a href="./button_text.html">Custom button text</a></li>
  156. <li><a href="./alter_buttons.html">Button arrangement</a></li>
  157. <li class="active"><a href="./ajax.html">Ajax loaded data</a></li>
  158. <li><a href="./pdf_message.html">PDF message</a></li>
  159. <li><a href="./jqueryui.html">jQuery UI styling</a></li>
  160. </ul>
  161. </div>
  162. </div>
  163. <div class="epilogue">
  164. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
  165. information about its API properties and methods.<br>
  166. Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
  167. <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
  168. DataTables.</p>
  169. <p class="copyright">DataTables designed and created by <a href=
  170. "http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
  171. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  172. </div>
  173. </div>
  174. </div>
  175. </section>
  176. </body>
  177. </html>