A problem occurred when using jquery's ajax callback function, that is, $(this) cannot be used in the callback function. I have been working on this problem for a long time, but I can't solve it. Later, I saved $(this) into a variable before calling the function, and then used it in the callback function. There was no problem. I will make a note here.
$(document).ready(function(){ $(“.del”).click(function () { obj=$(this).parent();//回调函数前先写入变量; delid=$(this).attr(‘delid’); $.get(‘drag.php’,{‘op’ : ‘del’,'id’ : delid},function(data){ if(data==1){ alert(‘删除成功’); obj.remove();//直接写$(this).parent()不会起作用。 }else{ alert(‘删除失败’); } }); }); });