84020

Loading indicator with dojo XHR requests

Question:

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.

Answer1:

Have a look at dojox.widget.Standby: <a href="http://dojotoolkit.org/reference-guide/dojox/widget/Standby.html" rel="nofollow">http://dojotoolkit.org/reference-guide/dojox/widget/Standby.html</a>

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

Recommend

  • Polymer Load Product Page data from JSON
  • Interpret Json response as plain text [duplicate]
  • How we can access the array objects of javascript passing through ajax in java?
  • Adding a billing method with google cloud results in “unexpected error”
  • Installing Help with Help Library Manager and WiX
  • base::assign(“.ptime”, proc.time(), pos = “CheckExEnv”) ERROR when using devtools::check
  • C# PCL HMACSHAX with BouncyCastle-PCL
  • Visual Studio 2015 XAML Resource Dictionary Error
  • Bluebird: getting the results of each()
  • Bundle install fails - Gem using github url - What is wrong?
  • Unity registration fails after iisreset
  • Appium MobileElement swipe returns unknown server error
  • Glassfish - java.lang.NoClassDefFoundError
  • Google analytics measurement protocol session timeout and query time limits
  • Undefined references when compiling gSOAP client
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • Loading .coffee files via a view in Rails
  • Create DicomImage from scratch using Dcmtk
  • Functions in global context
  • Play WS (2.2.1): post/put large request
  • why do I get the error when installing the gem 'pg'? [duplicate]
  • FileReader+canvas image loading problem
  • Master page gives error
  • Different response to non-authenticated users and AJAX calls
  • Google cloud sdk not working when python points python3
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Circular dependency while pushing http interceptor
  • Compare two NSDates in iPhone
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • Linking SubReports Without LinkChild/LinkMaster
  • Is it possible to post an object from jquery to bottle.py?
  • sending mail using smtp is too slow
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to load view controller without button in storyboard?