Update Database After Editing Form Using Ajax
I have asked many questions related to this, but still have not found a good answer. I get a lot of suggestions and questions, but I am not very good with Javascript or Ajax, so I
Solution 1:
You'll need to create a PHP file to handle the post from AJAX, receive the data and insert or update into the database. I assume you can handle the PHP portion. As for the AJAX, you just need to collect your data into an object and POST it to the server.
var postData = {}; //Object to hold your post variables.
postData.id = 2;
postData.name = "Roger";
postData.anythingElse = "Another string";
//And so on.
$.ajax({
url: "yourPHPfile.php",
type: "post",
data: postData,
success: function(response) {
console.log(response);
}
});
In the yourPHPfile.php
file, you will recieve those variables with POST.
$id = $_POST['id'];$name = $_POST['name'];$anythingElse = $_POST['anythingElse'];
Post a Comment for "Update Database After Editing Form Using Ajax"