jQuery.readyException()
JQ Home <<
Core & Internals <<
jQuery.when()
Handle 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.
Default behaviour is to re-throw the error as a timeout so that it's logged in the console and also passed to window.onerror
rather than being swallowed and lost.
The jQuery.readyException()
method was added in jQuery 3.1.
Syntax
Signature | Description |
---|---|
jQuery.readyException( error ) | Handle synchronously thrown errors that were wrapped in jQuery() functions. |
Parameters
Parameter | Description | Type |
---|---|---|
error | A JavaScript error object. | Error |
Return
A Selector
object.
jQuery.readyException( error )
Example
Core << Top
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(){
$('#btn18').one('click', function() {
var context = $('*').context;
jQuery.readyException = function( error ) {
window.setTimeout( function() {
throw error;
});
};
});
});
Related Tutorials
jQuery Basic Tutorials - Lesson 2 - jQuery Core & Internals