jQuery.readyException()S2C Home « Core & Internals « jQuery.readyException()
Handles synchronously thrown errors that were wrapped in jQuery() functions.
Shorthand version $.readyException()
Description
The jQuery.readyException() method fires when an Error JavaScript object is thrown synchronously from a jQuery() or jQuery( document ).ready() function or equivalent.
The jQuery.readyException() method was added in jQuery 3.1.
Syntax
| Signature | Description |
|---|---|
jQuery.readyException( error ) | Handles synchronously thrown errors that were wrapped in jQuery() functions. |
Parameters
| Parameter | Description | Type |
|---|---|---|
error | An error object. | Error |
Return
A Selector object.
jQuery.readyException( error ) ExampleTop
Re-throw caught error as a timeout so that it's logged in the console and also passed to window.onerror.
In the following example when we press the button the first time the jQuery.readyException() method gets fired.
$(function(){
$('#btn6').one('click', function() {
jQuery.readyException = function() {
window.setTimeout( function() {
throw error;
});
};
});
});