How To Save Edited Data From A Table Back To The Database With Jquery
I have a table where users can click on the row and then edit the row. I want to now be able to save it back to the database. How can I do this? I'm just not sure how to create the
Solution 1:
- One thing you would need connection to the database
you will need to ajax each row
$(document).ready(function() {
$('#btn').click(function(e)
{e.preventDefault(); $('#yourTable tr').each(function(i, tr) { var postData = { CoumnName : $('.row-class').val(), ColumnName : $('.row-class').val() } console.log(postData); $.ajax({ type: "post", url: "/your url", data: postData }) .done(function(response) { console.log(response); alert("Success!"); }) .fail(function(x, status, error) { alert("Error: " + error); }); }); });
});
Solution 2:
Here is what I came up with that works. I just use a php script to then save the data to the database.
functionsaveNewRowData(){
shapeName = $("input[name=shapeName]").val();
numberEdges = $("input[name=numberEdges]").val();
sumAngles = $("input[name=sumAngles]").val();
$.ajax({
type: "POST",
url: "saveNewData.php",
data: {shapeName: shapeName, numberEdges: numberEdges, sumAngles: sumAngles},
success: function(response){
}
});
}
Post a Comment for "How To Save Edited Data From A Table Back To The Database With Jquery"