YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
Connection Manager exposes Custom Events that track the progress of a transaction through its lifecycle. These Custom Events are raised at the global level and at the transaction level. The following code example provides a step-by-step approach to subscribing to global custom events raised by Connection Manager. In this scenario, an event handler object is created to handle all Custom Events. Each Custom Event is explicitly subscribed with a reference to it's event handler.
Click "Send a Request" below to try it out, then read the description below to learn how to subscribe to global Custom Events in Connection Manager.
Load the Yahoo Global Object and Connection Manager source file:
Construct a simple querystring with a key-value pair of s = hello world
. This data will be sent back to the client as a response from PHP to confirm the transaction.
Create an object to handle the global custom events fired by Connection Manager.
Let's create two functions to provide handlers for callback.success
and callback.failure
compatibility. The inclusion of these handlers will demonstrate the callback object's compatibility with Custom Events.
Subscribe to the global custom events fired by Connection Manager before starting the transaction.
Call YAHOO.util.Connect.asyncRequest
to make a request to get.php
, and PHP will return the contents of $_GET
via print_r()
.
Each event handler in globalEvents
will be triggered in response to its corresponding custom event(e.g., globalEvents.start will be called when startEvent fires). In this example, event handlers are created and subscribed to all possible events raised by Connection Manager.
Note: Logging and debugging is currently turned off for this example.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.