I want to redirect the user to another html page after a successful ajax request, but nothing happens. I have to mention the fact that the html page requires authentication, but at the moment the user makes the request he is logged in already.
This is the js:
$("form").submit(function (env) {
env.preventDefault();
$("#submitbtn").prop('disabled', true);
$("#form_result").text("");
var request = JSON.stringify($("#newRequest-form").serializeObject());
console.log(request);
$.ajax({
method: "POST",
url: "/api/holidays",
data: request,
contentType: "application/json",
dataType: "html",
success: function () {
window.location.href("summary.html");
/*$("#form_result").text("Submitted succesfully");
$("form").addClass('hidden');*/
},
error: function (error) {
$("#form_result").text("Error: creating the request. Status: " + error.status + " - " + error.statusText);
$("#submitbtn").prop('disabled', false);
}
});
});