ASYNCHRONOUS CODE

An introduction to callback functions

An example explaining why ne need callback functions.
To understand the difference between the wrong usage and the right usage of asynchronous calls, click on the buttons below,
then check out the implementation of these JavaScript functions: wrongUsage() and rightUsage().

In the next page we'll show how to use callback functions to improve animations management.

Remark: you can see the error due to the wrongUsage() only the first time the method is invoked.
To see the error more than once, probably you need to reload the whole page.

See the HTML source for details.

Sources

HOME