第一次单击删除链接时一切正常,但后续单击仅删除记录,而不会刷新“quotes”div。
我不确定我在这里忽略了什么。
我的 .js 文件:
$('.deleteRow').live('click', function (e) {
if (confirm('Delete?')) {
$.ajax({
type: 'POST',
url: this.href,
cache: false,
dataType: 'html',
success: function (response) {
$('#quotes').replaceWith(response);
$('#quotesTable').tablesorter().tablesorterPager({ container: $('#pager'), positionFixed: false });
}
});
}
return false;
});
和 html:
<tr>
<td>
Now is the time for all good men to come to the aid of their parties.
</td>
<td>
</td>
<td>
7/6/2010 10:13:44 PM
</td>
<td> <a class="editRow" href="/Quote/Edit/2">Edit</a></td>
<td> <a class="deleteRow" href="/Quote/Delete/2">Delete</a></td>
</tr>
<tr>
<td>
I'm a loser
</td>
<td>
146
</td>
<td>
7/6/2010 9:11:42 PM
</td>
<td> <a class="editRow" href="/Quote/Edit/1">Edit</a></td>
<td> <a class="deleteRow" href="/Quote/Delete/1">Delete</a></td>
</tr>
最佳答案
我正在 iPhone 上查看此内容,因此我看不到您的所有代码,但您可能应该使用“.html”而不是“.replaceWith”。前者替换指定标签内的内容,后者也删除标签。
关于asp.net - jQuery $.ajax 第一次工作,但在后续点击时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3380313/