ajax success error complete code example
Example 1: ajax error
$.ajax({
type: "post", url: "/SomeController/SomeAction",
success: function (data, text) {
},
error: function (request, status, error) {
alert(request.responseText);
}
});
Example 2: jquery ajax
$.ajax({
url : "file.php",
method : "POST",
data: {
action : action ,
key_1 : value_key_1,
key_2 : value_key_2
}
})
.fail(function() { return false; })
.done(function(data) {
console.log(data);
});
Example 3: jquery ajax on fail
fail: function(xhr, textStatus, errorThrown){
alert('request failed');
}