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

stateSaveCallback / stateLoadCallback with PHP

$
0
0

Hello,

I am trying to save the state of a datatable in a session via PHP but sadly I have do not have any success. Maybe someone can give me a helping hand.

Here the snippet from datatable:

"stateSaveCallback": function (settings, data) 
{  // Send an Ajax request to the server with the state object
   $.ajax( 
   {
      "url": "state_save.php",
      "data": data,
      "dataType": "json",
      "method": "POST"
   } );
}

Here the code of state_save.php (For testing, I just write it to a textfile):

$fp = fopen("test.txt","w");
fwrite($fp,var_dump($_POST));
fclose($fp);

The file is created, but it is empty.

When debugging the javascript, the variable "data" is filled with all values but it seems I am doing something wrong in the php part. Obviously reading from POST is not enough.

Since I was not able to find an example of a php code (maybe I was just blind), I would like to ask if someone is able to help me.

Thanks in adavance!

Dragon013


Viewing all articles
Browse latest Browse all 82249

Trending Articles



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