Nov

24

YUI - Connection Manager

November 24, 2007 |

Connection Manager, which deals with Ajax calls, is a very powerful part of the YUI as it allows you to create Ajax requests in a really easy syntax and meanwhile achieve cross-browser support.

There are three easy steps to take to make a simple ajax call using Connection Manager:

1 . define a handler object that has two properties, success and failure

var handlers = {
success: success,
failure: failure
}

2 . define the functions to respond to these handlers

function success( t ) {
alert( t.responseText );
}
function failure( t ) {
alert( 'There was an error: ' + t.statusText);
}

3 . instantiate the XHR with the YAHOO.util.Connect.asyncRequest() method

function init() {
call = YAHOO.util.Connect.asyncRequest('GET', 'text.html', handlers);
}
YAHOO.util.Event.onDOMReady(init);

I created a demo page below:


http://www.lab.highub.com/yui/connection-manager/



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

1 Comment so far

  1. rushda » Blog Archive » YUI - Connection Manager on November 24, 2007 4:30 pm

    [...] more here [...]

Sponsors




Links