ok, after that speech on DRY. I noticed your code said $('.control') lol. Call me stupid.
I am going to stick with my solution I posted previously so I can use it for things that don't have a class of control But If I were to implement your solution I would do it like this: (if you had something else in mind please let me know) <a> <img src="icon.png" url="doSomethingAwesome.php" class="control"> </a> Then for the script $('.control').click(function(){ $(this).replaceWith('<img src='wait.gif'>'); $(this.parentNode).load($(this).attr('url')); }); I haven't tested so it is probably written wrong. On Oct 11, 4:23 am, Wizzud <[EMAIL PROTECTED]> wrote: > ajaxSend is a global event that *every* bound listener will pick up. > You're binding listeners to all the elements that you *could* click on > to initiate the ajax call, but the ajax call does not know (or care) > what was clicked on, it just knows it has something to send. > > You must have click event handlers bound to the .control elements in > order to initiate the ajax call, so why not simply replace the image > on the clicked element prior to making the ajax call? > > eg. > $('.control').click(function(e){ > $(this)......// replace image with 'waiting' image > $.ajax(....); // make ajax call > }); > > On Oct 10, 3:38 pm, Mark <[EMAIL PROTECTED]> wrote: > > > 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>