File: ajax.reload%28%29.xml

package info (click to toggle)
datatables.js 1.10.21%2Bdfsg-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 22,604 kB
  • sloc: javascript: 64,254; xml: 10,441; php: 4,623; sh: 523; makefile: 21
file content (58 lines) | stat: -rw-r--r-- 2,231 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="UTF-8" ?>
<dt-api group="core">
	<name>ajax.reload()</name>
	<summary>Reload the table data from the Ajax data source</summary>
	<since>1.10</since>

	<type type="function">
		<signature>ajax.reload( callback, resetPaging )</signature>
		<parameter type="function" name="callback" default="null">
			Function which is executed when the data has been reloaded and the table fully redrawn. The function is given a single parameter - the JSON data returned by the server, and expects no return.
		</parameter>
		<parameter type="boolean" name="resetPaging" default="true">
			Reset (default action or `true`) or hold the current paging position (`false`). A full re-sort and re-filter is performed when this method is called, which is why the pagination reset is the default action.
		</parameter>
		<returns type="DataTables.Api">
			DataTables.Api instance
		</returns>
	</type>

	<description>
		In an environment where the data shown in the table can be updated at the server-side, it is often useful to be able to reload the table, showing the latest data. This method provides exactly that ability, making an Ajax request to the already defined URL (use `dt-api ajax.url()` if you need to alter the URL).
	</description>

	<example title="Reload the table data every 30 seconds (paging reset)"><![CDATA[
var table = $('#example').DataTable( {
	ajax: "data.json"
} );

setInterval( function () {
	table.ajax.reload();
}, 30000 );
]]></example>

	<example title="Reload the table data every 30 seconds (paging retained)"><![CDATA[
var table = $('#example').DataTable( {
	ajax: "data.json"
} );

setInterval( function () {
	table.ajax.reload( null, false ); // user paging is not reset on reload
}, 30000 );
]]></example>

	<example title="Use the callback to update an external elements"><![CDATA[
var table = $('#example').DataTable();

table.ajax.reload( function ( json ) {
	$('#myInput').val( json.lastInput );
} );
]]></example>

	<related type="option">ajax</related>
	<related type="api">ajax.json()</related>
	<related type="api">ajax.url()</related>
	<related type="api">ajax.url().load()</related>
	<related type="api">ajax.reload()</related>
	<related type="event">xhr</related>
</dt-api>