When you make an AJAX call, what "this" references changes

$('a.del').click(function() {
       var $parent = this.parent(); //i assume you want the parent of
the <a>
       $.post('/img/del.php') ,
             {'img': img },
             function(){
                  if (e.status == 'deleted') { //"e" of the original
function call?
                      $parent().remove();
                  }
             },
       'json');
       return false; //stops the <a>'s action
});

maybe if you better explain what you are trying to do, it would be
easier to point the path
On Jan 7, 7:16 am, runrunforest <craigco...@gmail.com> wrote:
> syntax a: not working, the parent of current element not being removed
>
>                         $('a.del').click(function(e){
>                                 e.preventDefault();
>                                 $.post('/img/del.php') ,
>                                                 {'img': img },
>                                                 function(e){
>                                                         if(e.status == 
> 'deleted') {$(this).parent().remove();}
>                                                 }, 'json');
>                         });
>
> syntax b: work but its not doing things correctly.
>
>                         $('a.del').click(function(e){
>                                 e.preventDefault();
>                                 $.post('/img/del.php'),
>                                                  {'img': img },
>                                                 function(e){
>                                                         if(e.status == 
> 'deleted') {}
>                                                 }, 'json');
>                                 $(this).parent().remove();
>                         });

Reply via email to