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

171
Views
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
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!