Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between .success() and .complete()?

Tags:

jquery

As of jQuery 1.5, all jQuery's AJAX methods return a jqXHR object that provides .error(), .success(), and .complete() methods.

What is the difference between .success() and .complete()?

like image 338
Rendicahya Avatar asked Mar 09 '11 03:03

Rendicahya


1 Answers

.success() only gets called if your webserver responds with a 200 OK HTTP header - basically when everything is fine.

However, .complete() will always get called no matter if the ajax call was successful or not - maybe it outputted errors and returned an error - .complete() will still get called.

It's worth mentioning that .complete() will get called after .success() gets called - if it matters to you.

  • http://api.jquery.com/ajaxComplete/
  • http://api.jquery.com/ajaxSuccess/
like image 51
arnorhs Avatar answered Oct 06 '22 01:10

arnorhs