ajax js sample code example
Example 1: ajax jquery example
$.ajax({
url : "file.php",
method : "POST",
data: {
//key : value
action : action ,
key_1 : value_key_1,
key_2 : value_key_2
}
})
.fail(function() { return false; })
// Appel OK
.done(function(data) {
console.log(data);
});
Example 2: ajax example
$.ajax({
method: "POST",
url: "/controller/action",
data: { name: "John", location: "Boston" },
success: (result) => {
console.log(result);
},
error: (error) => {
console.log(error);
}
});