代码之家  ›  专栏  ›  技术社区  ›  Mark Henry

成功调用Ajax后删除点击量

  •  0
  • Mark Henry  · 技术社区  · 7 年前

    虽然Ajax调用成功,但不会在末尾删除跨度。这里怎么了?

    <span><a title="remove resort from skiregion - are you sure?" id="xrr43" class="pointer remove_resort"> - remove resort </a></span>
    $('.remove_resort').on('click', function(e){ 
     e.preventDefault();    
     pos = $(this).attr("id");
     rem_res(pos);
    });    
    function rem_res(pos)
    {    
    $.ajax({
         type: 'GET',
         url: '/snowreport/request/remove.php',
         data: {
             res_id: pos
          },
         success: function(msg) {
         $(this).fadeOut(800, function() {
         $(this).html(msg).fadeIn().delay(2000);
         $(this).parent().remove().delay(2000);
                    });
                }
         });
     }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   flyingfox    7 年前

    你需要使用 id this

    success: function(msg) {
         $(“#”+pos).fadeOut(800, function() {
            $(this).html(msg).fadeIn().delay(2000);
            $(this).parent().remove().delay(2000);
         });
    }