SharePoint.Ajax.DataLoader

Purpose: Loads Xml data from a URL and calls the method of the reference passed in as parameters.

Usage:
SharePoint.Ajax.DataLoader(url,'set_Xsl',this);

Definition:

// Loads XML data specified in the path.
SharePoint.Ajax.DataLoader = function(path, method, reference){
// path: the URL to the Xml resource
// method: the method name (a quoted literal)
// the object reference to the component with the method
// remarks - the method must take an Xml object as the parameter
var request = new Sys.Net.WebRequest();
debug.trace("Data load: "+ path);
var userContext = new Object();
userContext.method = method;
userContext.object = reference;
request.set_userContext(userContext);
request.set_url(path);

request.add_completed(SharePoint.Ajax.DataLoaderHandler);
request.invoke();
}

// A common callback for the XML Data Loader.
// Calls the method sent in the userContext as a callback delegate.
SharePoint.Ajax.DataLoaderHandler = function (response){
var delegate = response.get_webRequest().get_userContext().method;
var obj = response.get_webRequest().get_userContext().object;
xml = response.get_xml();
eval('obj.' + delegate + '(xml)');
}

Last edited Dec 26, 2006 at 7:11 PM by daniellarson, version 1

Comments

No comments yet.