[jQuery] ajaxSend one call, many separate events
Let's say I have 10 icons on a web page. Clicking an icon will change
it from it's colored version to it's gray scale version. Changing
flag states if you will. Lets say, just for example, it takes 3 - 5
seconds for the icon to change because it has to wait on the server to
process the request and return the icon that represents the result
(special icon for failures). I want a wait image to replace the icon
that was clicked while waiting on the server.
I have tried something like this
$('.control').ajaxSend(
function() {
$(this).replaceWith('images/wait.gif');
});
This:
$('.control').ajaxSend(
function(evt) {
$(evt.target).replaceWith('images/wait.gif');
});
and This:
$('.control').each(
function() {
$(this).ajaxSend(
function() {
$(this).replaceWith('images/wait.gif')
}
)
});
They all give me the same result... all the objects with the class
'control' are replaced with the wait image and not just the one that
was clicked. I thought for sure the last one would work ;(.
<strong>Plain Text Test</strong>