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?

  1. $.ajax({   url: someurl,   success: function(){      //some code if ajax request successful   },   error: function(){     //some code if ajax request fails   } }) 

  2. $.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

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -