DataTables Post Ajax Method
DataTables Post Ajax Method

Hello, I'm new to Jquery and just getting use to datatables.
Right now I'm trying to create a button that will send back all table data back to the server. Right now im doing it via function that collects the table elements and then passes it through via ajax however its a bit messy. I just came across the POST data
section in which this example was displayed.
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"url": "scripts/post.php",
"type": "POST"
},
"columns": [
{ "data": "first_name" },
{ "data": "last_name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "start_date" },
{ "data": "salary" }
]
} );
} );
Can this snippet be used for the approach im trying to take? So that when I click a submit button this function is loaded and the data is sent back?
This question has an accepted answers - jump to answer
Answers
Are you using PHP / MySQL or .NET on the server side? if so I can warmly recommend to get Editor. Editor will handle it all for you. The license is dirt cheap and it is a great product. I am not affiliated with or sponsored by SpryMedia. This is just my personal opinion ...
@rf1234 - Cheque is in the post ;-)
@ravashjalil - Drop the
"serverSide": true,
option.serverSide
enables server-side processing, which you don't want if you are returning all of the data.Sure - have the event handler for your button call the
ajax.reload()
method. You can also useajax.data
as a function to submit data to the server on each request (for example form fields).Allan