YUI 3.x Home -

YUI Library Examples: IO: GET Transaction

Note: This is YUI 3.x. Looking for YUI 2.x?

IO: GET Transaction

This example demonstrates how to send HTTP GET requests, using IO. One transaction uses Global event listeners to handle the transaction lifecycles and response. The other transaction uses both Global and Transaction events.

  • IO GET response data will appear here.

Using IO for HTTP GET Requests, and Handling the Response via Event Listeners.

Create a YUI Instance

Create a YUI instance, using IO, for this example:

Create Handlers for Global and Transaction Events.

We will create one object to handle the Global Events, and one object to handle Transaction Events. Each object defines methods to handle the events in a transction's lifecycles. The results are logged to <div id="container">.

Subscribe to the Global events

With the handler object gH

Assemble a Configuration Object to set Transaction Event Listeners

Use a configuration object to define which Transaction Events you wish to handle, for the specific transaction.

Initiate the Transaction

Finally, we set up two buttons -- one for each type of transaction -- and add a "click" listener to each of them. The handler -- function call() -- make an IO request, based on which button was clicked.

Full Code

The full JavaScript code for this example follows:

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings