Yes - you can save using AJAX. One possible approach:
- When a user clicks save, run a loop in javascript to gather the fields of each row into an object, and add it to an array; a structure like:
var table_data = [
{field1:value1, field2:value2, field3: value3...}, // one of these for every row in the table
]
fieldX would be the names of your column headers, and valueX would be the values of those fields.
- Using ajax, post the data to a server-side script. An example using jQuery:
$ajax.({
type : 'POST',
url : 'script.php',
data : { 'submit_data' : table_data }
});
- On the server in a file called script.php, receive the POST'ed data, and then run a loop over the data to save each row to the table. Here's a sparse example, using PHP and mysqli:
$mysqli = database_connection();
$data = $_POST['submit_data']; //sanitize this!
foreach($data as $row){
$mysqli->query( "INSERT INTO data_table (field1, field2, field3) VALUES($row['field1'], $row['field2'], $row['field3'])" );
}
Bear in mind the above is very unsafe for a production environment; at a minimum, you should use prepared statements and parameter binding to insert the data: https://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php
I hope this gets you going. GL!