What you can do (in fact, what I did) is write a thin wrapper around the Request object. You can then extend this wrapper to transparently handle things like file uploads and JSONP through the same (or a very similar) interface, as well as have it automatically retry requests that fail. I also use this class to ensure that requests, their times, and their size are logged -- I can then get clients to forward these data through to me, which facilitates debugging.

In my implementation, I only show a "please wait" message after a short moment (around 250ms) -- this way, really quick requests (which should dominate) won't cause unsightly flickers. Using the wrapper also means that I can ensure that only one message is shown, rather than stacking them.

- Barry

On 28/11/11 13:39, Philip Thompson wrote:
Not exactly what I'm looking for because I don't want to add the spinner options to every request object - I want to add the spinner to the Request prototype. Is it possible to add the spinner options to the prototype and have it applied to all Requests?

Thanks,
~Philip


On Nov 27, 2011, at 10:25 PM, Aaron Newton wrote:

See Spinner in MooTools More.


On Nov 27, 2011, at 8:13 PM, Philip Thompson <[email protected] <mailto:[email protected]>> wrote:

Hi all.

It seems like I've seen something similar before, but I can't seem to find it. I am wanting to show a default "Loading…" message/icon when a Request occurs. In a previous project several years ago, I (re-)implemented the methods necessary in Request to add the loader to every request. It seems like there should be an easier way. David has done some similar functionality here (http://davidwalsh.name/dwrequest-mootools-12-ajax-listener-message), but I don't want to call a custom class, I just want to use the base Request(.HTML/.JSON) class with this added functionality.

I tried overwriting the main request class, but the onRequest and onComplete methods never seem to get called.
http://jsfiddle.net/philthathril/kpAUC/

What is the proper way to accomplish this? Is there already a solution out there that I just can't find?

Thanks in advance,
~Philip

--
http://lonestarlightandsound.com/


--
Barry van Oudtshoorn
www.barryvan.com.au

Not sent from my Apple ?Phone.

Reply via email to