Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/02/2012, 20:46
quebien
 
Fecha de Ingreso: febrero-2007
Mensajes: 309
Antigüedad: 17 años, 2 meses
Puntos: 16
Como acceder objeto padre jquery?

Hola! tengo el siguiente codigo que realiza una llamada ajax cuando se hace clic en un boton, y quiero que cuando termine le cambie el src a la imagen del boton. Pero no puedo acceder al objeto desde dentro de la funcion (marcado en rojo) ¿como tendria que hacer?

Código:
$(function(){
		$( ".btnSwitch" ).click(function(){
			$(this).attr("src", "img/ajax-loader-mini.gif");
			$.ajax({
			  url: "admin_ajax.php",
			  data: "switch=1&id="+$(this).attr("regid")+"&tabla=<?=$tabla?>&campo=visible&campoId=id",
			  cache: false,
			  success: function(msg){
			  	console.log($(this).attr("regid"));
			    if(msg=='OK'){
			    	if($(this).attr("estado") == 1){
			    		$(this).attr("src", "img/offline.png");
				    	$(this).attr("estado", 0);
			    	}else{
				    	$(this).attr("src", "img/online.png");
				    	$(this).attr("estado", 1);
			    	}
			    }
			  }
			});
		});
	});
__________________
Responder encuestas