Filed under: portal.xn--b8qr95do2b.com — smith @ March 12, 2010 edit
I got this code from the XML portfolio tutorial and use it all the time. Works good. But just for my own curiousity why are all the 'Success' arguments needed? The function wouldn' be called until it is properly loaded anyway right? (i.e. onLoad automatically checks this?). And why the second 'success' with the if statement. Just trying to understand..
My_xml.onLoad = function(success) {
if (success) {
doSomething(this);
}
}The XML.onLoad() event handler is triggered when the XML object receives a response from the server. 99 times out of a 100 that response should be the xml file you requested. It may, though, be an error ("file not found", "server timeout", etc). If you get the correct xml file, the success argument is true otherwise it's false.. Usually, an "else" condition is also included to do something in case there is an error.. Something like this:
My_xml.onLoad = function(success:Boolean) {
if (success) {
trace("xml loaded successfully..");
// perform xml actions
} else {
trace("a server error was received and xml wasn't loaded..");
// perform error actions
}
};
It isn't necessary to include the "success" argument, but if you don't and some error occurs while loading your xml file, the end user may be hung up forever waiting for something to happen..OK, makes sense. Thanks.#If you have any other info about this subject , Please add it free.# |
|