I have an Dynamic HTML table I am simply calling the id using JavaScript, looping through the data and capturing the cell values.
Question- How do I take this data POST it to test save.php page to insert the entire table into my MySQl db ?
var table = document.getElementById('table'),
rows = table.getElementsByTagName('tr'),
i, j, cells, OS_d,roleApp_d,Men_d,vcpu_d,Val_d,Per_d,hw_d ;
for (i = 1, j = rows.length; i < j; ++i) {
cells = rows[i].getElementsByTagName('td');
if (!cells.length) {
continue;
}
OS_d = cells[1].firstChild.value;
roleApp_d = cells[2].firstChild.value;
vcpu_d = cells[3].firstChild.value;
Men_d = cells[4].firstChild.value;
Val_d = cells[5].firstChild.value;
Per_d = cells[6].firstChild.value;
hw_d = cells[7].firstChild.value;
}
--- Section where assistance is required
$.ajax({
type: "POST",
url: 'Save.php',
data: ({data:OS_d, roleApp_d, vcpu_d, Men_d, Val_d, Per_d, hw_d}),
success: function(data) {
alert(data);
}
});
PHP Side Save.php
<?php
$test = $_POST['data'];
echo $test;
?>