tpl) by defining the handler for the click event
of your ???Save for later??? links and Remove buttons and the handler for the submit event of the form. This way, when
JavaScript is available and these buttons or links are clicked, the JavaScript event handlers execute before the
browser has the chance to submit the form or follow the clicked link.
Then you created the necessary JavaScript code that implements the event handlers:
??? executeCartAction() is called from the shopping cart page to perform cart actions.
??? handleExecuteCartAction() is the callback function for the cart action server calls.
??? postExecuteCartActionProcess() reads the cart action server response and updates the page
accordingly.
Finally, you updated index.php to return the HTML code of the shopping cart when it is requested by AJAX, and
voil? ! Your shopping cart is now faster and more user-friendly.
Summary
AJAX is cool, and so is our newly AJAX-enabled site! This wasn??™t a short and easy chapter, but what
you??™ve achieved (and learned!) will prove to be very useful in the future. Of course, the range of
AJAX features you can add to your web site is very wide, but right now you have the foundations
implemented, and your customers will certainly appreciate the AJAX touch you??™ve added to your
store.
CHAPTER 13 ?– IMPLEMENTING AJAX FEATURES 430
Accepting Customer Orders
Your new, shiny, AJAXified shopping cart is fully functional, except that it doesn??™t allow your
visitors to actually place orders, which is rather troubling since that is the point of all this! We??™ll
deal with that issue in this chapter in two separate stages:
??? First, we??™ll implement the visitor side of the order-placement mechanism.
Pages:
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545