Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

386
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda