Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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()?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

.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/
over 4 years ago · Santiago Trujillo Report

0

success() is called when the server returns a 200 status code, complete() is called always when the request is complete, no matter the outcome.

over 4 years ago · Santiago Trujillo Report

0

success() is called when the server returns success status code, like: 200, 201 etc.

complete() is called always when the request is complete. (no matter, it is success/error response from server.)


So,

  • when there is success response from server: success() and complete() is called.
  • when there is error response from server: error() and complete() is called.

Example: For what purpose you can use complete():
suppose in beforeSend() you show a loader image, and in complete(), you can hide that loader image.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!