Ajax删除div不起作用

时间:2014-05-17 12:25:13

标签: php jquery ajax codeigniter

我有以下脚本

 $('a[name=deleteButton]').on('click', function () {
        arr=[];
        var arr = $("input[name='post[]']:checked").map(function() { 
                return this.value; 
              }).get();
              var content = $(this).parents('tr').find('.key').html();
              $(this).parents('tr').fadeOut('slow', function() {$(this).remove();}); //THIS IS THE ONE WHICH FADES THE ROW 

              makeAjaxCall(content);

             return false;

    });

    function makeAjaxCall(content){
        $.ajax({
            type: "post",
            url: "http://localhost/partner/app/deleteRowUsingApiKey/delete",
            cache: false,               
            data: {id : content},
            success: function(data){                        
                   // alert(data);

            //BUT IM NOT ABLE TO USE IT HERE,IN THE SUCCESS

            },
            error: function(td){                        

            }
     });

    }

我有一行$(this).parents('tr').fadeOut('slow', function() {$(this).remove();}); 删除div.But我无法在ajax的成功中使用它。任何人都可以告诉我原因。

1 个答案:

答案 0 :(得分:3)

尝试,

在调用函数时传递$(this)引用,

makeAjaxCall(content,$(this));

收到它,

function makeAjaxCall(content, _this) {

并在成功回电中,

  success: function(data){ 
      _this.parents('tr').fadeOut('slow', function() {$(this).remove();});                 
  }
相关问题