ajax request post json code example
Example: jquery ajax post example
var formData = {name:"John", surname:"Doe", age:"31"}; //Array
$.ajax({
url : "https://example.com/rest/getData", // Url of backend (can be python, php, etc..)
type: "POST", // data type (can be get, post, put, delete)
data : formData, // data in json format
async : false, // enable or disable async (optional, but suggested as false if you need to populate data afterwards)
success: function(response, textStatus, jqXHR) {
console.log(response);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});