I used the submit button to perform the delete operation in mvc3. I want to show a confirmation window when I click the button, so I used below jquery. The query was used for static data, but I want to work with my database. When I click the submit button, a message appears, but even if I click "OK", an error message appears. What to 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"); } }); } } ); });
source share