$('.del').live('click', function() { var str = $(this).serialize() + '&js=true';
var $this = $(this); // set variable here $.ajax({ url: $(this).attr('action'), data: str, beforeSend: function() { }, success: function(data){ // use variable here console.log($this); }, error: function(xhr, status, error) { } }); return false; }); On Aug 4, 2:08 am, Jaggi <jaggi_2...@hotmail.com> wrote: > I'm using a ajax function but wish to return $(this) inside the > success function but can't seem to get it to work, can some one tell > me if its possible. If you look inside the success function i'm trying > to get $(this) from the click function. > > $('.del').live('click', function() { > var str = $(this).serialize() + '&js=true'; > > $.ajax({ > url: $(this).attr('action'), > data: str, > beforeSend: function() { > > }, > success: function(data){ > > console.log($(this)); > > }, > error: function(xhr, status, error) { > > } > }); > return false;}); > > } > return false; > });