Success message and redirect

I use the following AJAX call to update a certain table in the database:

$("#agenda_update_form").on("submit", function(e) {
    e.preventDefault();
    $.ajax({
        url : "/admin/update_optreden",
        type: "post",
        data: $(this).serialize(),
        success: function(data){
            window.alert("Optreden was succesvol gewijzigd");
        }
    });
});

As you can see do I have an alert box in the success function. What I would like to accomplish is to redirect to another page (/admin/agenda) after the ok button on the alert box was pressed. How do I do that?

Thank you in advance.

Hi donboe,

window.alert("Optreden was succesvol gewijzigd");
window.location = "/new/path/";

The alert will block further execution until the user presses OK.

Hi Pullo. Thanks for the reply very much apreciated :slight_smile: How are you doing?

Not too bad, man. Very busy with work, but that’s a good thing.
How about you?

Yeah quite busy my self as well, and that’s indeed a good thing :slight_smile: Speak to you soon, and again thank you

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.