I would like to delete a record in a button click by Jquery, what is the best way to do it? The way I did it is not working.
Action I want to call by Jquery
// POST: Pais/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Pais pais = db.Paises.Find(id);
pais.Delete();
return RedirectToAction("Index");
}
Event in Jquery where I want to call Action DeleteConfirmed
$('.btnExcluirSimPopover').on('click', function () {
if (handlePopover > 0) {
$.post("/Pais/DeleteConfirmed", { id: handlePopover }, function (data){
});
}
});