Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82775

AJAX Source table displays all records not 10

$
0
0
I use AJAX to load a json array into my table, the json does validate

I initialize my table with this


$(function () {
    if(jQuery().dataTable) {
      var oTable =  $('#thetable').dataTable({
			"oLanguage": {
				"sEmptyTable": "No data"
			},
            "bProcessing": true,
			"bServerSide": true,
            "sAjaxSource":'http://example.com/json.php',
			"fnServerParams": function ( aoData ) {
				aoData.push({ "name": "post_id", "value":'<?php echo $pageID; ?>'  } );
			},
            "aoColumns": [
        { "mDataProp": "post_id","bSortable": false },
        { "mDataProp": "url" },
		{ "mDataProp": "page_type" },
        { "mDataProp": "cat" },
		{ "mDataProp": "tags" },
		{ "mDataProp": "country_code" },
        { "mDataProp": "action_buttons","bSortable": false } 
		]
	});

    }
});

I have compared the XHR from my website to the demo at http://datatables.net/release-datatables/examples/server_side/server_side.html

The query string parameters below are the same on my server and the demo, these are being sent to the server with datatables that I know.

sEcho:1
iDisplayStart:0
iDisplayLength:10

My response from the server in the beginning of the json file is

iTotalDisplayRecords: "54"
iTotalRecords: "54"
sEcho: 1

In the json array are all 54 rows of data.

I think what I need is deferred loading? http://datatables.net/release-datatables/examples/server_side/defer_loading.html

But there is no code example. Or is that not what I need? I've read over what I should be sending to the server, and what I should send back but can't figure out how to get 10 rows to display in my table with the json response.

Thanks in advance.

Viewing all articles
Browse latest Browse all 82775

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>