ajax.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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
  42. sourced data</a> in the DataTable. Note that no special initialisation is required. Responsive is
  43. enabled by adding the <code class="string" title="String">responsive</code> class to the <code class=
  44. "tag" title="HTML tag">table</code> element.</p>
  45. </div>
  46. <table id="example" class="display responsive nowrap" 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. &quot;ajax&quot;: &quot;../../../../examples/ajax/data/objects.txt&quot;,
  81. &quot;columns&quot;: [
  82. { &quot;data&quot;: &quot;name&quot; },
  83. { &quot;data&quot;: &quot;position&quot; },
  84. { &quot;data&quot;: &quot;office&quot; },
  85. { &quot;data&quot;: &quot;extn&quot; },
  86. { &quot;data&quot;: &quot;start_date&quot; },
  87. { &quot;data&quot;: &quot;salary&quot; }
  88. ]
  89. } );
  90. } );</code>
  91. <p>In addition to the above code, the following Javascript library files are loaded for use in this
  92. example:</p>
  93. <ul>
  94. <li><a href="../../../../media/js/jquery.js">../../../../media/js/jquery.js</a></li>
  95. <li><a href=
  96. "../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
  97. <li><a href="../../js/dataTables.responsive.js">../../js/dataTables.responsive.js</a></li>
  98. </ul>
  99. </div>
  100. <div class="table">
  101. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
  102. DataTables:</p>
  103. </div>
  104. <div class="css">
  105. <div>
  106. <p>This example uses a little bit of additional CSS beyond what is loaded from the library
  107. files (below), in order to correctly display the table. The additional CSS used is shown
  108. below:</p><code class="multiline brush: js;">div.container { max-width: 1200px }</code>
  109. </div>
  110. <p>The following CSS library files are loaded for use in this example to provide the styling of the
  111. table:</p>
  112. <ul>
  113. <li><a href=
  114. "../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
  115. <li><a href="../../css/dataTables.responsive.css">../../css/dataTables.responsive.css</a></li>
  116. </ul>
  117. </div>
  118. <div class="ajax">
  119. <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
  120. will update automatically as any additional data is loaded.</p>
  121. </div>
  122. <div class="php">
  123. <p>The script used to perform the server-side processing for this table is shown below. Please note
  124. that this is just an example script using PHP. Server-side processing scripts can be written in any
  125. language, using <a href="//datatables.net/manual/server-side">the protocol described in the
  126. DataTables documentation</a>.</p>
  127. </div>
  128. </div>
  129. </section>
  130. </div>
  131. <section>
  132. <div class="footer">
  133. <div class="gradient"></div>
  134. <div class="liner">
  135. <h2>Other examples</h2>
  136. <div class="toc">
  137. <div class="toc-group">
  138. <h3><a href="./index.html">Basic initialisation</a></h3>
  139. <ul class="toc active">
  140. <li><a href="./className.html">Class name</a></li>
  141. <li><a href="./option.html">Configuration option</a></li>
  142. <li><a href="./new.html">`new` constructor</a></li>
  143. <li class="active"><a href="./ajax.html">Ajax data</a></li>
  144. </ul>
  145. </div>
  146. <div class="toc-group">
  147. <h3><a href="../styling/index.html">Styling</a></h3>
  148. <ul class="toc">
  149. <li><a href="../styling/bootstrap.html">Bootstrap styling</a></li>
  150. <li><a href="../styling/foundation.html">Foundation styling</a></li>
  151. </ul>
  152. </div>
  153. <div class="toc-group">
  154. <h3><a href="../display-control/index.html">Display control</a></h3>
  155. <ul class="toc">
  156. <li><a href="../display-control/auto.html">Automatic column hiding</a></li>
  157. <li><a href="../display-control/classes.html">Class control</a></li>
  158. <li><a href="../display-control/init-classes.html">Assigned class control</a></li>
  159. </ul>
  160. </div>
  161. <div class="toc-group">
  162. <h3><a href="../child-rows/index.html">Child rows</a></h3>
  163. <ul class="toc">
  164. <li><a href="../child-rows/disable-child-rows.html">Disable child rows</a></li>
  165. <li><a href="../child-rows/column-control.html">Column controlled child rows</a></li>
  166. <li><a href="../child-rows/right-column.html">Column control - right</a></li>
  167. <li><a href="../child-rows/whole-row-control.html">Whole row child row control</a></li>
  168. <li><a href="../child-rows/custom-renderer.html">Custom child row renderer</a></li>
  169. </ul>
  170. </div>
  171. </div>
  172. <div class="epilogue">
  173. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
  174. information about its API properties and methods.<br>
  175. Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
  176. <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
  177. DataTables.</p>
  178. <p class="copyright">DataTables designed and created by <a href=
  179. "http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
  180. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  181. </div>
  182. </div>
  183. </div>
  184. </section>
  185. </body>
  186. </html>