Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created September 18, 2009 19:30
Show Gist options
  • Select an option

  • Save lsmith/189240 to your computer and use it in GitHub Desktop.

Select an option

Save lsmith/189240 to your computer and use it in GitHub Desktop.
(function() {
var YCM = YAHOO.util.Connect,
pending = [];
function _handleStart(e, a) {
console.log("Transaction " + a[0].tId + " is starting.", "info", "example");
}
function _handleSuccess(o) {
var area = YAHOO.util.Dom.get('output');
YAHOO.plugin.Dispatcher.process(area, o.responseText, {rel:'main-area'});
}
function _handleFailure(o) {
console.log("ERROR " + o.id + " " + o.argument, "info", "example");
}
YCM.startEvent.subscribe(_handleStart);
YCM.transport('/yui2/build/connection/connection.swf');
function _crossDomainAjaxRequest(url, responseContainer) {
console.log("url is " + url);
var obj = YCM.asyncRequest('GET',
url,
{
success: _handleSuccess,
failure: _handleFailure,
xdr: true
}
);
}
YCM.xdrReadyEvent.subscribe(function () {
YAHOO.plugin.KVC.crossDomainAjaxRequest = _crossDomainAjaxRequest;
for (var i = 0, len = pending.length; i < len; ++i) {
_crossDomainAjaxRequest.apply(YAHOO.plugin.KVC, pending[i]);
}
});
YAHOO.namespace("plugin.KVC").crossDomainAjaxRequest = function () {
// XDR isn't ready yet, so hold onto the method arguments to try again later
pending.push(arguments);
};
})();
YAHOO.register("kvc", YAHOO.plugin.KVC, {version: "0.1"});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment