使用dojo XHR请求加载指示符 [英] Loading indicator with dojo XHR requests

查看:173
本文介绍了使用dojo XHR请求加载指示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用dojo,而且我正在使用dojo xhrGet,xhrPost等..进行大量的ajax调用。现在我有一个动画GIF图像,我想用来表示加载给用户。我不太清楚如何做到这一点。有人可以告诉我这个吗?这里是我的代码,

  dojo.xhrGet({
url:registcarturl,
handleAs:json
preventCache:true,
load:function(data,ioArgs){
// DO STUFF WITH data HERE
},
error:function(error) {
alert(抱歉!使用ajax添加到购物车时发生错误);
}
});

我如何将gif文件加载到互动中?谢谢。

解决方案

看看 dojox.widget.Standby http://dojotoolkit.org/reference-guide/dojox/widget/Standby。 html



给你一个例子,定义 widget.Standby

 < div jsId =basicStandby1dojoType =dojox.widget.Standbytarget =yourDomTarget> 

调用 dojo.xhrGet 后,显示:

  basicStandby1.show(); 

收到您的答案时,请隐藏:

  basicStandby1.hide(); 


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

这篇关于使用dojo XHR请求加载指示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆