Can I relocate to a new url after click the ok button using sweet alert?

this is my javascript file, where should I place here the code if its possible thank you

$(document).ready(function() {
    $('#formA').on('submit', function(e) { //Don't foget to change the id form
        $.ajax({
            url: 'includes/Aenduser.inc.php', //===PHP file name====
            data: $(this).serialize(),
            type: 'POST',
            success: function(data) {
                console.log(data);
                //Success Message == 'Title', 'Message body', Last one leave as it is
                swal('¡Success!', 'Request sent!', 'success');

            },
            error: function(data) {
                //Error Message == 'Title', 'Message body', Last one leave as it is
                swal('Oops...', 'Something went wrong :(', 'error');
            }
        });
        e.preventDefault(); //This is to Avoid Page Refresh and Fire the Event 'Click'
    });
});

You can use teh jquery/javascript method -

window.location.href = '/some/new/page';

Youn will put this in the next lines of code whehn your post was successful -

success: function(data) {
                console.log(data);
                //Success Message == 'Title', 'Message body', Last one leave as it is
                swal('¡Success!', 'Request sent!', 'success');
                window.location.href = 'goingtomynextpagenow.php';
            },
commented: thanks for the comment, however it still not redirecting to another url, I have double checked the pagename and your advice, anyother way to do this? +0

possibly because the 'href' property needs to be a full URL?

This works for me in my browser console

window.location.href = 'https://www.google.co.uk';

commented: Thanks Biiim for picking up on my typo. @Ryan_42, did this solve your problem? +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.