Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo callback before AJAX

Does Dojo xhrPost / xhrGet has an equivalent callback function as jQuery beforeSend?

like image 922
Diogo Cardoso Avatar asked Nov 03 '22 17:11

Diogo Cardoso


1 Answers

You can use dojo/aspect.

aspect.before(dojo, "xhrGet", function(args){
    args.url = 'index.html?TEST';
    return [args];
});

var btn = new Button({label: 'xhr'}, 'btn');
on(btn, 'click', function(evt){
    var xhrArgs = {
        url: "index.html",
        handleAs: "text",
        load: function(data){ console.debug(data); },
        error: function(error){ console.error(error);}
    }
    dojo.xhrGet(xhrArgs);
});

http://dojotoolkit.org/reference-guide/1.7/dojo/aspect.html

like image 80
Craig Swing Avatar answered Nov 09 '22 07:11

Craig Swing