Dorokhov.codes
AJAX
Create an AJAX request (default method is GET
):
let ajax = $.ajax({
url: "/index.php",
data: {
name : "Andrew",
weight : 85
}
});
Using callbacks:
$.ajax({
url: "/index.php",
data: {
name : "Andrew",
weight : 85
},
success: function() {
alert("success");
},
error: function() {
alert("error");
},
complete: function() {
alert("complete");
}
});
Or:
ajax.done(function() {
alert( "success" );
});
ajax.fail(function() {
alert( "error" );
});
ajax.always(function() {
alert( "complete" );
});