It can be that you are doing an ajax request and a normal post after, because you are not preventing the default behavior. Try preventing the default behavior:
$(function () {
$('form').submit(function (e) { // Add the event parameter -> e
// Prevent the default behavior.
e.preventDefault();
$.ajax({
url: "@Url.Action( "Active", "Account")",
type: "post",
data: { code: $('#ActivationCode').val() },
success: function (result) {
console.log("successful\n" + result);
},
error: function (request, status, error) {
console.log("error");
}
});
// Also return false for the default behavior.
return false;
});
});
From jQuery documentation:
event.preventDefault()
If this method is called, the default action of the event will not be triggered.
Returning false
is also a way to tell the event to not actually fire.