Redirecting to another url after form submission using javascript

I want my form to post to a specific url through the action attribute, but redirect to a thank you page.

I have tried this

  $(function() {
  $('.profile-form').submit(function(){
    $.post('/?target=profile', function() {
      window.location = '/thank-you-prize-wheel.html';
    });
    return false;
  });
});

The above code redirects the page but doesn’t post to the specified URL, not even if I use an absolute path

what am I doing wrong?

Well since the success callback gets executed, it seems that the request does get sent successfully. If you comment out the redirect, what does the response look like in the network panel?

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