You have to pass the args variable to the anonymous function, but the anonymous function does not visibly need the args variable, so you have to memorize when Dojo needs the args variable, but the Dojo help page doesn't say! So, when does Dojo need the args variable?
var init = function(){
var contentNode = dojo.byId("content");
dojo.xhrGet({
url: "js/sample.txt",
handleAs: "text",
load: function(data,args){
// fade out the node we're modifying
dojo.fadeOut({
node: contentNode,
onEnd: function(){
// set the data, fade it back in
contentNode.innerHTML = data;
dojo.fadeIn({ node: contentNode }).play();
}
}).play();
},
// if any error occurs, it goes here:
error: function(error,args){
console.warn("error!",error);
}
});
};
dojo.addOnLoad(init);