Ajax and Serverside=true just shows processing. (Resolved)
Ajax and Serverside=true just shows processing. (Resolved)
dblu
Posts: 11Questions: 0Answers: 0
Update again: Several hours later I tried many things and decided to switch DataTables Get to a POST and that fixed it. Hopefully this will help someone.
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"sAjaxSource": "<?php //echo base_url();?>clients/ClientsSource"
} );
} );
[/code]
I was using the wrapper for Codeignitor and it was returning data but overall was not working. After 6 hours I finally decided to use the script that is on DataTables website here, http://www.datatables.net/release-datatables/examples/data_sources/server_side.html and then it worked right away. It seems one has sEcho working right and the other does not.
{“sEcho”:1,“iTotalRecords”:“50”,“iTotalDisplayRecords”:“50”,“aaData”:[[“1”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“2”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“3”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“4”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“5”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“6”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“7”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“8”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“9”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“10”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”]]}
https://github.com/IgnitedDatatables/Ignited-Datatables
I have no idea what bit of code is causing the trouble. JSON looks the same otherwise besides scolumns.
bServerSide does need to be true.
Original post:
Hello thank you for your time, I have looked through all the literature. If I turn Serverside off, then it shows only 10 rows of data and the buttons trigger functions but nothing happens.
The data is coming back fine as this:
[code]
{"sEcho":0,"iTotalRecords":"50","iTotalDisplayRecords":"50",
"aaData":[["1","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["2","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["3","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["4","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["5","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["6","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["7","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["8","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["9","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["10","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"]],
"sColumns":"id,first_name,last_name,organization,address,city,state,zip"}
[/code]
However, I have 50 entries in the database. my drop down and pagination button events are not being triggered and am guessing if because is says it has 50 entries in the DB and I get this “Showing 1 to 10 of 10 entries”
It should be Showing 1 to 10 of 50 entries I would think.
any thoughts? I have this for JS:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "<?php echo base_url();?>clients/ClientsSource"
} );
} );
[/code]
I am using ajax. So what is it in DataTables that is causing this or what do I not have setup right to get it to show up to all 50 and all the buttons work? I have tried all I can think of and am sure if it was the wrapper it would be returning bad data in JSON above.
To Update this, using bServerSide set to true just show the Loading screen. It seems this is a no brainer but can someone tell me am I doing something DataTables can't do? It is the JS that seems to be the trouble. It appears the data comes in but then the javascript goes through some jquery and then it just ends and I see no errors. The JSON is sitting there but DataTables is crashing somewhere.
Any thoughts at all? Anyone? I am running this on XAMPP. I thought that was an issue but if it was then I should not be getting any JSON in the first place.
Thanks.
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"sAjaxSource": "<?php //echo base_url();?>clients/ClientsSource"
} );
} );
[/code]
I was using the wrapper for Codeignitor and it was returning data but overall was not working. After 6 hours I finally decided to use the script that is on DataTables website here, http://www.datatables.net/release-datatables/examples/data_sources/server_side.html and then it worked right away. It seems one has sEcho working right and the other does not.
{“sEcho”:1,“iTotalRecords”:“50”,“iTotalDisplayRecords”:“50”,“aaData”:[[“1”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“2”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“3”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“4”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“5”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“6”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“7”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“8”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“9”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”],[“10”,“MyFirst”,“MyLast”,“MyOrg”,“MyAddress”,“MyCity”,“MyState”,“MyZip”]]}
https://github.com/IgnitedDatatables/Ignited-Datatables
I have no idea what bit of code is causing the trouble. JSON looks the same otherwise besides scolumns.
bServerSide does need to be true.
Original post:
Hello thank you for your time, I have looked through all the literature. If I turn Serverside off, then it shows only 10 rows of data and the buttons trigger functions but nothing happens.
The data is coming back fine as this:
[code]
{"sEcho":0,"iTotalRecords":"50","iTotalDisplayRecords":"50",
"aaData":[["1","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["2","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["3","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["4","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["5","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["6","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["7","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["8","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["9","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"],
["10","MyFirst","MyLast","MyOrg","MyAddress","MyCity","MyState","MyZip"]],
"sColumns":"id,first_name,last_name,organization,address,city,state,zip"}
[/code]
However, I have 50 entries in the database. my drop down and pagination button events are not being triggered and am guessing if because is says it has 50 entries in the DB and I get this “Showing 1 to 10 of 10 entries”
It should be Showing 1 to 10 of 50 entries I would think.
any thoughts? I have this for JS:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "<?php echo base_url();?>clients/ClientsSource"
} );
} );
[/code]
I am using ajax. So what is it in DataTables that is causing this or what do I not have setup right to get it to show up to all 50 and all the buttons work? I have tried all I can think of and am sure if it was the wrapper it would be returning bad data in JSON above.
To Update this, using bServerSide set to true just show the Loading screen. It seems this is a no brainer but can someone tell me am I doing something DataTables can't do? It is the JS that seems to be the trouble. It appears the data comes in but then the javascript goes through some jquery and then it just ends and I see no errors. The JSON is sitting there but DataTables is crashing somewhere.
Any thoughts at all? Anyone? I am running this on XAMPP. I thought that was an issue but if it was then I should not be getting any JSON in the first place.
Thanks.
This discussion has been closed.