Change an Image after a Success AJAX Call

Change an Image after a Success AJAX Call

Hi,

I've a list of items and an image displaying if the item it's available or not. I already have a link on the image and a script that switch status of the record, all this using AJAX. However I want to switch the image after success of AJAX request.

So my code for AJAX:
  1. $('table#lista-boleias td#status a.switch').click(function(){
  2. var actImg = $(this).find('img').attr('id');
  3. var image = $(this).find('img');
  4. $(this).html('<img src="_assets/process.gif" id="loadwait" alt="Loading..."/>').fadeIn("slow"); 
  5. var id = $(this).parent().parent().attr('id');
  6. var data = 'bid=' + id + '&uid=<%=user%>';
  7. $.ajax(
  8. {
  9.   type: "GET",
  10.   url: "ajax/switchboleia.asp",
  11.   data: data,
  12.   cache: false,
  13.   success: function(){
  14.  
  15.   $("#loadwait").hide();
  16. $('img.switch').show();
  17. if (actImg == 'act'){
  18. $(this).src = ('_assets/inactiva.png').fadeIn("slow");
  19. //$.image.src = ('_assets/inactiva.png').fadeIn("slow");
  20. } else {
  21. $(this).src = ('_assets/activa.png').fadeIn("slow");
  22. //$.image.src = ('_assets/activa.png').fadeIn("slow");
  23. }
  24. image.show();
  25.   }
  26. });
  27. });
My problem is in the success function, the image is inside of a.switch, so I'm trying to retrieve the ID of the image and if the image ID is "act" change the image source to the inactive.png image, else change to active.

The switchboleia.asp page, only sets the status of the item ID, sended by GET, to active or inactive, but in the end I want to show it to user change the image source. What I'm missing here?