Hi I am trying to execute an ajax call to the server but I seem to have no luck I keep getting back on the console an error 500 Internal server error.This is my ajax call:
    $("body").on("click", "#ok", function (e) {
    var id = $(this).attr("data-bookid");
    $.ajax({
        url: "/ProductEditor/DeleteBook",
        type:"POST",
        data: { bookId: parseInt(id) },
        success: function (data) {
            console.log(data);
        },
        error: function (data) {
            console.log(data);
        }
    });
    e.preventDefault();
})
And this is the C# code I am trying to call:
public ActionResult DeleteBook(int bookId)
{
   bookRepository.DeleteBook(bookId);
   return RedirectToAction("Books", "ProductManager");
}
While trying to debug I have noticed that the DeleteBook method is not even called.
What am I doing wrong?
EDIT I have added the [HttpPost] attribute but it still does not work