开发者

Loading indicator with dojo XHR requests

I only recently started using dojo and I am doing numerous ajax calls using dojo xhrGet, xhrPost,..开发者_开发技巧etc. Now I have an animated gif image which i want to use to indicate "loading" to the user. I am not too sure how this can be done. Can someone please advise me on this? here is my code,

dojo.xhrGet({
                url: registcarturl,
                handleAs: "json",
                preventCache: true,
                load: function(data, ioArgs) {
                    //DO STUFF WITH data HERE
                },
                error: function(error) {
                    alert("sorry ! an error occurred while adding to the cart with ajax");
                }    
           });

How do i get my loading gif file into the interaction? Thank you.


Have a look at dojox.widget.Standby: http://dojotoolkit.org/reference-guide/dojox/widget/Standby.html

To give you an example, define the widget.Standby

<div jsId="basicStandby1" dojoType="dojox.widget.Standby" target="yourDomTarget">

After calling dojo.xhrGet, show it:

 basicStandby1.show();

And when you receive your answer, hide it:

basicStandby1.hide();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜