Chapter 3. Javascript Events: Reacting to your users

image with no caption

Sometimes you need your code to react to other things going on in your web application... and that’s where events come into the picture. An event is something that happens on your page, in the browser, or even on a web server. But it’s not enough to just know about events... sometimes you want to respond to them. By creating code, and registering it as an event handler, you can get the browser to run your handler every time a particular event occurs. Combine events and handlers, and you get interactive web applications.

It all started with a downward-facing dog...

Marcy’s just opened up a new yoga studio that caters to programmers and techies. She wants a website that shows the different levels of classes she offers, the times they’re available, and provides new customers a way to enroll in a class... all in a cool, intuitive package. But she doesn’t have a clue how to build that kind of site.... that’s where you come in.

To give you an idea of what she’s looking for, Marcy worked up a quick sketch of what a page on her site needs to show her customers:

image with no caption

Get Head First Ajax 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.