![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to disable some jQuery global Ajax event handlers for a request?
Use the global error handler to receive a few of the parameters that jQuery can provide. After that add the suppressErrors: true. You can try to run the following code to disable some jQuery global Ajax event handlers for a request:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div.log").ajaxError(function(evt, xhr, settings) { if(settings.suppressErrors) { return; } $(this).text( "ajaxError handler is triggered" ); }); $("button.trigger").click(function() { $("div.log").text(''); $.ajax("ajax/missing.html"); }); $("button.triggerSuppress").click(function() { $("div.log").text(''); $.ajax( "ajax/missing.html", { suppressErrors: true }); }); }); </script> </head> <body> <button class="trigger">Trigger (process errors)</button> <button class="triggerSuppress">Trigger (won't process errors)</button> <p>Check log</p> <div class="result"></div> <div class="log"></div> </body> </html>
Advertisements