vendredi 1 juillet 2016

dataTables form submit with pagination cant get all data

I have a form with dataTables, once submitted it will get all the data and save it into the database. but since dataTables pagination is true, currently it is only saving the data that are shown and the rest are not saved.

$('#uploadClicked').click(function () {
var table = $('#dataTable-ageGroup').DataTable();
var data = table.$('input, select').serialize();
var json = JSON.stringify(data);                                              
document.getElementById('json').setAttribute('value', json);
alert("The following data would have been submitted to the server:     
nn" +  data);
document.getElementById('UploadDb').submit(); return false;}); 

tried to do this but the result is in a form that i dont understand...

location=Barangay+1&ageGroup=All+Ages&bothSexes=2197&male=1086&female=1111&location=Barangay+1&ageGroup=Under+1&bothSexes=42&male=17&female=25&location=Barangay+1&ageGroup=1+-+4&bothSexes=169&male=88&....

if this is the only way without using ajax, how can i translate this data into json form?? or any another way where i can turn that data into an object

Aucun commentaire:

Enregistrer un commentaire