saveState is not working properly.
saveState is not working properly.
george001
Posts: 14Questions: 5Answers: 3
Im using this bit of code to save my dtable's state in my database but it doesn't save it. Instead I am getting 0 on the column that
it was supposed to save the table's state.
Why?
//SaveState
'stateSaveCallback': function(settings, data) {
$.ajax({
'url': 'saveDtableState.php',
'data': { 'name': 'resultsTable', 'data': data },
'dataType': 'json',
'method': 'POST'
});
},
PHP
$dataTable_name = $_POST['name'];
$dataTable_state = $_POST['state'];
$userID = 'random1';
if(!empty($userID)){
$stateSave_query = mysql_query("INSERT INTO $table_name (userID, dtable_name, dtable_state) VALUES ('$userID', '$dataTable_name', '$dataTable_state')")or die(mysql_error());
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Do you have this
in your DataTable initialization?
@tangerine Yes I do, on the first line!
Happy to take a look at a test case showing the issue. Given that you are defining the
stateSaveCallback
, I presume you are also definingstateLoadCallback
, but that isn't shown above.Allan
@allan hello, I fixed that problem.. It was a database error. I hadn't included the stateLoadCallback at that time but now that I did it breaks down the whole table.
that is the whole code that i have for my datatable
@allan what happens is that, when I include the stateLoadCallback the datatable becomes a normal table..
found the problem... my back-end was wrong... this is what should look like:
Thanks for posting back. Good to hear you've got it working.
Allan