javascript - which one should be used in case of jquery ajax call, success/ error callback or done()/fail() chain function -
sometimes if ajax call has returned error, calls done() chain function rather fail(). confused whether use success/error callback or done()/fail() chain function.
for eg 1 advisable 1 or 2?
$.ajax({ url: someurl, success: function(){ //some code if ajax request successful }, error: function(){ //some code if ajax request fails } })
$.ajax({ url: someurl }).done(function(){ //some code changes }).fail(function(){ //some code changes });
these interchangeable ways of doing ajax call in jquery. second method describe uses promises, whereas first method handles successes/errors options on ajax call.
Comments
Post a Comment