jquery async code example
Example 1: get request jquery
$.get( "ajax/test.html", function( data ) {
$( ".result" ).html( data );
alert( "Load was performed." );
});
Example 2: jquery ajax post
$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});
Example 3: jquery ajax promise
$.ajax({
url: "/someurl",
method: "GET",
data: {
a: "a"
})
.done(function(data) {
console.log('success callback 1', data)
})
.done(function(data) {
console.log('success callback 2', data)
})
.fail(function(xhr) {
console.log('error callback 1', xhr);
})
.fail(function(xhr) {
console.log('error callback 2', xhr);
});