5

Dojo xhrPost / xhrGet是否具有与 jQuery beforeSend等效的回调函数?

4

1 回答 1

2

您可以使用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

于 2012-08-31T17:44:20.927 回答