ajax.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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>Responsive example - Ajax 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.responsive.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. div.container { max-width: 1200px }
  14. </style>
  15. <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.js"></script>
  16. <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js"></script>
  17. <script type="text/javascript" language="javascript" src="../../js/dataTables.responsive.js"></script>
  18. <script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
  19. <script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
  20. <script type="text/javascript" language="javascript" class="init">
  21. $(document).ready(function() {
  22. $('#example').DataTable( {
  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. } );
  33. } );
  34. </script>
  35. </head>
  36. <body class="dt-example">
  37. <div class="container">
  38. <section>
  39. <h1>Responsive example <span>Ajax data</span></h1>
  40. <div class="info">
  41. <p>This example shows the Responsive extension working with <a href="//datatables.net/manual/data">Ajax sourced data</a> in the DataTable. Note that no special
  42. initialisation is required. Responsive is enabled by adding the <code class="string" title="String">responsive</code> class to the <code class="tag" title=
  43. "HTML tag">table</code> element.</p>
  44. </div>
  45. <table id="example" class="display responsive nowrap" 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. &quot;ajax&quot;: &quot;../../../../examples/ajax/data/objects.txt&quot;,
  79. &quot;columns&quot;: [
  80. { &quot;data&quot;: &quot;name&quot; },
  81. { &quot;data&quot;: &quot;position&quot; },
  82. { &quot;data&quot;: &quot;office&quot; },
  83. { &quot;data&quot;: &quot;extn&quot; },
  84. { &quot;data&quot;: &quot;start_date&quot; },
  85. { &quot;data&quot;: &quot;salary&quot; }
  86. ]
  87. } );
  88. } );</code>
  89. <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
  90. <ul>
  91. <li><a href="../../../../media/js/jquery.js">../../../../media/js/jquery.js</a></li>
  92. <li><a href="../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
  93. <li><a href="../../js/dataTables.responsive.js">../../js/dataTables.responsive.js</a></li>
  94. </ul>
  95. </div>
  96. <div class="table">
  97. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
  98. </div>
  99. <div class="css">
  100. <div>
  101. <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
  102. additional CSS used is shown below:</p><code class="multiline language-css">div.container { max-width: 1200px }</code>
  103. </div>
  104. <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
  105. <ul>
  106. <li><a href="../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
  107. <li><a href="../../css/dataTables.responsive.css">../../css/dataTables.responsive.css</a></li>
  108. </ul>
  109. </div>
  110. <div class="ajax">
  111. <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
  112. loaded.</p>
  113. </div>
  114. <div class="php">
  115. <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
  116. processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
  117. documentation</a>.</p>
  118. </div>
  119. </div>
  120. </section>
  121. </div>
  122. <section>
  123. <div class="footer">
  124. <div class="gradient"></div>
  125. <div class="liner">
  126. <h2>Other examples</h2>
  127. <div class="toc">
  128. <div class="toc-group">
  129. <h3><a href="./index.html">Basic initialisation</a></h3>
  130. <ul class="toc active">
  131. <li><a href="./className.html">Class name</a></li>
  132. <li><a href="./option.html">Configuration option</a></li>
  133. <li><a href="./new.html">`new` constructor</a></li>
  134. <li class="active"><a href="./ajax.html">Ajax data</a></li>
  135. <li><a href="./default.html">Default initialisation</a></li>
  136. </ul>
  137. </div>
  138. <div class="toc-group">
  139. <h3><a href="../styling/index.html">Styling</a></h3>
  140. <ul class="toc">
  141. <li><a href="../styling/bootstrap.html">Bootstrap styling</a></li>
  142. <li><a href="../styling/foundation.html">Foundation styling</a></li>
  143. <li><a href="../styling/scrolling.html">Vertical scrolling</a></li>
  144. <li><a href="../styling/compact.html">Compact styling</a></li>
  145. </ul>
  146. </div>
  147. <div class="toc-group">
  148. <h3><a href="../display-control/index.html">Display control</a></h3>
  149. <ul class="toc">
  150. <li><a href="../display-control/auto.html">Automatic column hiding</a></li>
  151. <li><a href="../display-control/classes.html">Class control</a></li>
  152. <li><a href="../display-control/init-classes.html">Assigned class control</a></li>
  153. <li><a href="../display-control/fixedHeader.html">With FixedHeader</a></li>
  154. <li><a href="../display-control/complexHeader.html">Complex headers (rowspan / colspan)</a></li>
  155. </ul>
  156. </div>
  157. <div class="toc-group">
  158. <h3><a href="../child-rows/index.html">Child rows</a></h3>
  159. <ul class="toc">
  160. <li><a href="../child-rows/disable-child-rows.html">Disable child rows</a></li>
  161. <li><a href="../child-rows/column-control.html">Column controlled child rows</a></li>
  162. <li><a href="../child-rows/right-column.html">Column control - right</a></li>
  163. <li><a href="../child-rows/whole-row-control.html">Whole row child row control</a></li>
  164. <li><a href="../child-rows/custom-renderer.html">Custom child row renderer</a></li>
  165. </ul>
  166. </div>
  167. </div>
  168. <div class="epilogue">
  169. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
  170. 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>
  171. which extend the capabilities of DataTables.</p>
  172. <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2015<br>
  173. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  174. </div>
  175. </div>
  176. </div>
  177. </section>
  178. </body>
  179. </html>