Loading indicator with dojo XHR requests

风格不统一 提交于 2019-12-13 03:19:00

问题


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.


回答1:


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();


来源:https://stackoverflow.com/questions/7601079/loading-indicator-with-dojo-xhr-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!