Calling a function within a onLoad

I’m trying to call a function with a onLoad function in a Class

Any reason why this doesn’t work?

XML_var.onLoad = function(success) {
anotherFunction();
}

Thanks