I m using jquery datatables first time, so now i done table like this
everything works perfectly. now i m using this below javascript code
$(document).ready(function() {
$('#example').dataTable(
{
"pageLength": 50,
'sDom': 'l' ,
} );
$('#example tfoot th').each( function ()
{
var title = $('#example thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" style="width:100%;" id="munna_'+title+'" placeholder="Search '+title+'" />' );
});
var table = $('#example').DataTable();
table.columns().every( function ()
{
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
that
.search( this.value )
.draw();
});
});
$('#munna_button').click( function()
{
var data = table.$('input, select').serialize();
alert(JSON.stringify(data))
return false;
});
});
now this code returns value like this in rate_14=67&rate_15=87&rate_67=88 etc..,
now i dont have idea how to store this on SUBMIT. normally on submit i get $_POST['name'] like this, now please some one hlep me from this.
Simply use ajax to send the information:
$('#munna_button').click( function(){
var data = table.$('input, select').serialize();
$.post('url_link_here', data, function(returnData){
//success -- do stuff with returnData if there is any
}).fail(function(){
//failed
});
});
You could store the serialized data into a hidden variable added to form. and in java script use some like this to save the value in hidden field
$('#serialize_data').val(JSON.stringify(data));
After the form is submitted, you will find the value in
$_POST['serialize_data']
If you don't want to submit the form , you can use ajax to send data to .php script I hope this will help you