Member Avatar for feoperro

Hi,

Does anyone know how to add an ajax loader to the remember the milk validation example? So that while the backend is busy, it shows the gif, when it's finished, it hides the gif...

Thanks,
Ashton.

try the ajaxSend()

http://api.jquery.com/ajaxSend

Look at the example right before the section titled "Example". By looking at the settings.url (or perhaps settings.data) you will be able to know which field is triggering the request )

Member Avatar for feoperro

I don't understand :(

So that while the backend is busy, it shows the gif, when it's finished, it hides the gif...

That tells me that you are emitting an ajax request (somehow - most likely using the "remote" validation option). If that is the case, then is you use the jquery ajaxSend() method, before the request is actually sent you will be able to "know" that the request is about to be "emitted". So at that point you show your image.

Imagine you initially have

<div id="myloader"><img src="imageloader.gif" .../></div>

also, in your css you may have:

#myloader{display:none}

then in your ajaxSend() method you can do $("#myloader").show()

ajaxSend() is part of the jquery's $.ajax() utility. Under the hood, the remote option will be using $.ajax(). So if you use ajaxSend() as suggested, it will be "honored".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.