Is your document ready to submit?

Sometimes, it can happen that you submit your document when its half finished without knowing that it still needs to be processed further. Such an event triggers a chain of events that will eventually make your page or app go into the service-fail mode.

Using jQuery, this is something that happens rarely as it provides the $(document).ready() method, which will help to complete of the processing the document. A simple example can be seen here:

$(document).ready(function() {
  console.log('ready!');
});

The function will execute and will be passed to .ready() once the document is ready. We are using $(document) to create a jQuery object from the page's document. We will then call the .ready() function on that object, ...

Get Mastering JavaScript Promises now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.