jQuery deferred.catch() Method Last Updated : 22 Jul, 2024 Comments Improve Suggest changes Like Article Like Report The deferred.catch() method in jQuery is used to add handlers which are to be called when the deferred object is rejected. Syntax:deferred.catch(failedFilter)Parameters:failedFilter: This parameter specifies a function which is to be called when the deferred object is rejected.Return Value: This method returns the deferred object. Example 1: html <!DOCTYPE HTML> <html> <head> <script src= "https://code.jquery.com/jquery-3.5.0.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p> JQuery | deferred.catch() method </p> <button onclick="Geeks();"> click here </button> <script> function Geeks() { $.get("testingGFG.php") .then(function () { alert( "$.get successfully completed!"); }) .catch(function () { alert("$.get failed!"); }); } </script> </body> </html> Output:Before clicking on button:After clicking on button:Example 2: html <!DOCTYPE HTML> <html> <head> <script src= "https://code.jquery.com/jquery-3.5.0.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p> JQuery | deferred.catch() method </p> <button onclick="Geeks();"> click here </button> <p id="GFG_DOWN"></p> <script> var el_down = document .getElementById("GFG_DOWN"); function Geeks() { $.get("testingGFG.php") .then(function () { el_down.innerHTML = "$.get successfully completed"; }) .catch(function () { el_down.innerHTML = "$.get failed!"; }); } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article jQuery deferred.catch() Method P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JQuery jQuery-Methods Similar Reads JQuery .Deferred() method This JQuery.Deferred() method in JQuery is a function which returns the utility object with methods which can register multiple callbacks to queues. It calls the callback queues, and relay the success or failure state of any synchronous or asynchronous function.Syntax:jQuery.Deferred([beforeStart])P 2 min read jQuery deferred.always() Method This deferred.always() method in jQuery is used to add handlers which are to be called when the Deferred object is resolved or when it is rejected. The arguments specified can be either a single function or an array of functions.Syntax:deferred.always( alwaysCallbacks [, alwaysCallbacks] )Parameters 2 min read jQuery deferred.fail() Method The deferred.fail() method in jQuery is used to add handlers which are to be called when the Deferred object is rejected. This method accepts one or more than one arguments, which can be either a function or an array of functions. Callbacks are executed in the same order they were added. When the De 2 min read jQuery deferred.done() Method This deferred.done() method in jQuery is used to add handlers which are to be called when the deferred object is resolved.Syntax:Â deferred.done(Callbacks [, Callbacks])Parameters:Callbacks: This parameter specifies a function, or array of functions, which are called when the Deferred is resolved.Cal 1 min read JQuery deferred.then() method This deferred.then() method in JQuery is used to add handlers which are to be called when the Deferred object is resolved, rejected, or in progress. Syntax: deferred.then(doneCallbacks[, failCallbacks][, progressCallbacks])Parameters: doneCallbacks: This is a function, or an array of functions, whic 3 min read Like