这是代码的一部分
<script type="text/javascript" src="~/scripts/jquery.unobtrusive-ajax.js"></script>
Ajax.ActionLink("Yes", "Delete", "Notes", new { id = item.NoteId }, new AjaxOptions { HttpMethod = "POST", OnComplete = "javascript:void(0);" }, new { id = item.NoteId, @class = "yes" });
单击它应该调用以下操作:
[HttpPost]
public bool Delete(int id)
{
Notes notes = db.Notes.Find(id);
db.Notes.Remove(notes);
db.SaveChanges();
return true;
}
它确实 - 笔记被删除了。但是由于某种原因,该方法被调用了 5 或 8 次。
POST http://localhost:57904/Notes/Delete/41 500 (Internal Server Error) jquery-1.8.2.min.js:2
POST http://localhost:57904/Notes/Delete/41 500 (Internal Server Error) jquery-1.8.2.js:8416
POST http://localhost:57904/Notes/Delete/41 500 (Internal Server Error) jquery-1.8.2.min.js:2
POST http://localhost:57904/Notes/Delete/41 500 (Internal Server Error) jquery-1.8.2.js:8416
额外电话的原因可能是什么?