0

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);
        }
    });
});
Harshil Sharma
  • 2,016
  • 1
  • 29
  • 54
Gustavo
  • 3,461
  • 7
  • 26
  • 41

1 Answers1

2
window.location.href("summary.html");

is not a function, it's a property. Try this:

window.location.href = "summary.html";
Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59