What I want to do is get all the data from the table and send it as a autoincremented multi-dimensional array with ajax using the post method. When it gets to the server it should be like:
$_POST -|-- ['Key1'] = 'value1' <---This is from an HTML input
|-- ['Key2'] = 'value2' <---This is from an HTML input
|-- ['tabledata']--| -- [0]-| -- ['column1'] = 'value from cell'
| | -- ['column2'] = 'value from cell'
| -- [1]-| -- ['column1'] = 'value from cell'
| -- ['column2'] = 'value from cell'
[0] and [1] are just autoincremented numbers generated when a new array object is created representing first and second row in this case. Here is a js fiddle with what I got so far (it returns array but not the way I need them) https://jsfiddle.net/v2quhwb8/2/ with the JS:
$(document).ready(function() {
var myTable = $('#example').DataTable({
responsive: true
});
var testData = myTable.data().toArray();
$('#myButton').on('click', function() {
$.ajax({
type: 'POST',
dataType: 'json',
url: 'page/postTest.php',
data: testData,
success: function(response) {
// console.log('Server response', response);
}
});
});
});
key1andkey2and what are its values?['ajax'][0]must be array of column values? and here is[0]a key or a index?