I have used a submit button to perform delete operation in mvc3. I want to show a confirmation box when I click the button so I used the below jquery. The query was used for static data but I want to work with my data base. When I click to the submit button the message appears but even if i click ok it shows error message. What should I do to make it work.
<script type="text/javascript">
$(document).ready(function () {
$("#button").click(function (event) {
event.preventDefault();
var link = this;
if (confirm("Are you sure that you want to delete this user?")) {
$.ajax({
type: "POST",
url: link.href,
success: function (data)
{
$(link).parents("tr").remove();
alert("deleted");
},
error: function (data)
{
event.preventDefault();
alert(" Unsuccessful");
}
});
}
}
);
});