Ah i did try that but it didn't output anything (using firebug). But when i just tried adding it now and just running it in the code the code seems to work (still doesn't output anything tho). Must be one of those things, thanks.
On Aug 4, 7:20 pm, James <james.gp....@gmail.com> wrote: > $('.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; > > });