mirror of
https://github.com/DataTables/DataTables.git
synced 2024-12-04 16:24:11 +01:00
2b6788011f
- DataTables 1.9 had 5 different parameters that controlled how Ajax data was obtained, which with its own naming properties, often mapping to the jQuery.ajax methods, or otherwise extending them. To hugely simply and extend the Ajax functionality DataTables has, these five parameters have now been deprecated and the funtionality provided by them merged into the new `ajax` parameter. - Deprecated properties: - sAjaxSource - fnServerData - sAjaxDataProp - sServerMethod - fnServerParams - Note that these parameters are still fully supported and can be used, but for new projects, `ajax` should be used as they will eventually be removed (likely DataTables v2 whenever that is, as they are too widely used to be removed in v1.x). - Added additional / missing tests for the deprecated properties to ensure full backwards compatiblity - The new `ajax` property is fully documented in the doc comments, but as a summary it can take three forms: - string - the url to get the data from (i.e. this is the new sAjaxSource) - object - maps directly to jQuery.ajax, allowing full control of the Ajax call (provides the abilities of fnServerParams, sServerMethod, sAjaxDataProp) - function - a function so you can get the data your own way (provides the abilities of fnServerData) - Added unit tests for the new `ajax` property and doc comment examples updated to use this property exclusively.
50 lines
1.0 KiB
JavaScript
50 lines
1.0 KiB
JavaScript
// DATA_TEMPLATE: empty_table
|
|
oTest.fnStart( "sServerMethod" );
|
|
|
|
|
|
$(document).ready( function () {
|
|
/* Check the default */
|
|
var oTable = $('#example').dataTable( {
|
|
"sAjaxSource": "../data_sources/method.php?method=get"
|
|
} );
|
|
|
|
oTest.fnWaitTest(
|
|
"Default method was GET",
|
|
null,
|
|
function () {
|
|
// A valid request will place a single row in the table
|
|
return $('tbody td').eq(0).html() === '1';
|
|
}
|
|
);
|
|
|
|
oTest.fnWaitTest(
|
|
"Can make a POST request",
|
|
function () {
|
|
oSession.fnRestore();
|
|
$('#example').dataTable( {
|
|
"sAjaxSource": "../data_sources/method.php?method=post",
|
|
"sServerMethod": "POST"
|
|
} );
|
|
},
|
|
function () {
|
|
return $('tbody td').eq(0).html() === '1';
|
|
}
|
|
);
|
|
|
|
oTest.fnWaitTest(
|
|
"Can make a PUT request",
|
|
function () {
|
|
oSession.fnRestore();
|
|
$('#example').dataTable( {
|
|
"sAjaxSource": "../data_sources/method.php?method=put",
|
|
"sServerMethod": "PUT"
|
|
} );
|
|
},
|
|
function () {
|
|
return $('tbody td').eq(0).html() === '1';
|
|
}
|
|
);
|
|
|
|
oTest.fnComplete();
|
|
} );
|