Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
Bypass jQuery ajax success handler based on response type

How can I bypass ajax success callbacks and run global success handler based on the response I get from the server?

$(document).ajaxSuccess(function (event, xhr, settings) {
    if(xhr.responseText=="ignoreCustomSuccessHandler");
        console.log("from global");
});
$.ajax({
    success: function(data){
      console.log("from success");
   }
})

So if I get ignoreCustomSuccessHandler from the server, I want only the global success handler to run and ignore the one defined in success. That is, my log should be from global only.

Otherwise, my success callback should run, giving me the output from success.

I can check the condition inside success and get the desired result, but I am trying to write minimal code that can be applied to all ajax requests in my project.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda