1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-04 16:24:11 +01:00
DataTables/media/unit_testing/data_sources/method.php

54 lines
854 B
PHP
Raw Normal View History

<?php
if ( strcasecmp( $_GET['method'], $_SERVER['REQUEST_METHOD'] ) === 0 ) {
pass();
}
else {
fail();
}
function pass()
{
if ( isset($_REQUEST['sEcho']) ) {
// Server-side processing
echo json_encode( array(
'sEcho' => intval( $_REQUEST['sEcho'] ),
'iTotalRecords' => 1,
'iTotalDisplayRecords' => 1,
'aaData' => array(
array(1, 2, 3, 4, 5)
)
) );
}
else {
// Client-side processing
echo json_encode( array(
'aaData' => array(
array(1, 2, 3, 4, 5)
)
) );
}
}
function fail()
{
if ( isset($_REQUEST['sEcho']) ) {
// Server-side processing
echo json_encode( array(
'sEcho' => intval( $_REQUEST['sEcho'] ),
'iTotalRecords' => 0,
'iTotalDisplayRecords' => 0,
'aaData' => array()
) );
}
else {
// Client-side processing
echo json_encode( array(
'aaData' => array()
) );
}
}