diff --git a/examples/server_side/jsonp.html b/examples/server_side/jsonp.html new file mode 100644 index 00000000..e2d32704 --- /dev/null +++ b/examples/server_side/jsonp.html @@ -0,0 +1,188 @@ + + + + + + + DataTables example + + + + + + +
+
+ DataTables server-side processing example with JSONP +
+ +

Preamble

+

JSONP is a method of using JSON data from any server, regardless of XSS protection that modern browsers use. It is very useful for being able to retrieve JSON data from any domain name you choose and is easy to integrate with DataTables, thanks to jQuery's Ajax handler, as shown in this example.

+ +

Live example

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
Loading data from server
Rendering engineBrowserPlatform(s)Engine versionCSS grade
+
+
+ + +

Initialisation code

+
$(document).ready(function() {
+	$('#example').dataTable( {
+		"bProcessing": true,
+		"bServerSide": true,
+		"sAjaxSource": "scripts/jsonp.php",
+		"fnServerData": function( sUrl, aoData, fnCallback ) {
+			$.ajax( {
+				"url": sUrl,
+				"data": aoData,
+				"success": fnCallback,
+				"dataType": "jsonp",
+				"cache": false
+			} );
+		}
+	} );
+} );
+ + +

Other examples

+

Basic initialisation

+ + +

Advanced initialisation

+ + +

Data sources

+ + +

Server-side processing

+ + +

API

+ + +

Plug-ins

+ + + +

Please refer to the DataTables documentation for full information about its API properties and methods.

+ + + +
+ + \ No newline at end of file diff --git a/examples/server_side/scripts/jsonp.php b/examples/server_side/scripts/jsonp.php new file mode 100644 index 00000000..a5d96ed2 --- /dev/null +++ b/examples/server_side/scripts/jsonp.php @@ -0,0 +1,174 @@ + intval($_GET['sEcho']), + "iTotalRecords" => $iTotal, + "iTotalDisplayRecords" => $iFilteredTotal, + "aaData" => array() + ); + + while ( $aRow = mysql_fetch_array( $rResult ) ) + { + $row = array(); + for ( $i=0 ; $i \ No newline at end of file