ajax.html 7.3 KB

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