jQuery的不能正常工作,如果里面的AJAX后成功/失败不能正常、里面、工作、jQuery

由网友(烫一壶浊酒)分享简介:我刚开始学习AJAX张贴之前我已经搜查,refered以previous问像this但它并没有帮助还有我的code是:I have just started learning AJAX Before posting I have already searched and refered to previous...

我刚开始学习AJAX 张贴之前我已经搜查,refered以previous问像this但它并没有帮助 还有我的code是:

I have just started learning AJAX Before posting I have already searched and refered to previous asked questions like this but it didn't helped well My Code is:

$('.del').click(function(){
    $(this).parent().hide('slow');
    $.get( "index.php", {del:$(this).attr('id')}).done(function(data){
        if (data==='1') {
            $(this).parent().remove();
        }
        else{
            $(this).parent().show('slow');
        }
    });
});

如果在 jQuery的声明以及其他不执行验证每一件事情进行的很顺利我有添加了一个警告的声明,并弹出成功,但jQuery的语句是不是working.Whats的问题,以及如何解决这一问题?

the jquery statements inside if as well as else is not executed To verify every thing is going well I had added an alert in the statements and it popped up successfully but the jquery statements isn't working.Whats The problem and how to fix this ?

推荐答案

我相信你的 $(本)引用不正确,在该范围内。尝试:

I believe your $(this) reference is incorrect in that scope. Try:

$('.del').click(function(){
    var $this = $(this);
    $this.parent().hide('slow');
    $.get( "index.php", {del:$this.attr('id')}).done(function(data){
        if (data==='1') {
            $this.parent().remove();
        }
        else{
            $this.parent().show('slow');
        }
    });
});