Basic question (working with POST + basic table construction)
Basic question (working with POST + basic table construction)
So i'm just getting started with this AMAZING plugin (congrats!) and am running into an issue getting it set up. Basically, i THINK everything is fine, but I get an "Added data does not match number of columns" error, which seems strange, the table and JSON are definitely set up correctly. Code follows:
[code]
var oTable;
$(document).ready(function() {
oTable = $('#participants').dataTable({
"bAutoWidth": false,
"bSortClasses": false,
"bStateSave": false,
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "/rest/smsreplies",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "campaign_id", "value": "xxx" } );
$.ajax( {
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
});
});
function reload() {
oTable.fnReloadAjax();
}
setInterval("reload();", 10000); ///////// 10 seconds
[/code]
Json:
[code]
{
"aaData" :
[ "2010-04-23 19:42:50",
"9178414441",
"Matthew",
"Hensrud"
]
}
[/code]
And finally, the html:
[code]
Participation Time
Number
First Name
Last Name
[/code]
Pretty straightforward.. basically I want the table refreshed from the server every few seconds, I'll add more fancy behaviors later, like handling how to highlight new data, etc...
Thanks in advance!
[code]
var oTable;
$(document).ready(function() {
oTable = $('#participants').dataTable({
"bAutoWidth": false,
"bSortClasses": false,
"bStateSave": false,
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "/rest/smsreplies",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "campaign_id", "value": "xxx" } );
$.ajax( {
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
});
});
function reload() {
oTable.fnReloadAjax();
}
setInterval("reload();", 10000); ///////// 10 seconds
[/code]
Json:
[code]
{
"aaData" :
[ "2010-04-23 19:42:50",
"9178414441",
"Matthew",
"Hensrud"
]
}
[/code]
And finally, the html:
[code]
Participation Time
Number
First Name
Last Name
[/code]
Pretty straightforward.. basically I want the table refreshed from the server every few seconds, I'll add more fancy behaviors later, like handling how to highlight new data, etc...
Thanks in advance!
This discussion has been closed.
Replies
I have another question though - which I'm posting in a separate thread. :)