-1

This is my code:

function mySubmit() {
  var myForms = document.getElementsByTagName("form");
  var userEmail = document.getElementById("myEmail").childNodes[0].nodeValue;

  for (var t = 0; t < myForms.length; t++){
    myForms[t].s_emailaddress.value = userEmail 
    $.post("http://test.test", $(myForms).eq(t).serialize(), function (data, status) {
      if (status === "success") {

I'd like to add a redirect function to this. For example, all form data should be submitted and upon submission, redirect to www.google.com

Cjmarkham
  • 9,484
  • 5
  • 48
  • 81
badsmell
  • 75
  • 11
  • Word to the wise, you should really format your code better. It makes it easier for you and everyone else to read and debug it. – Mike Cluck Aug 15 '16 at 19:44

2 Answers2

0
if (status === "success") {
  window.location = 'https://google.com';
}
Jekrb
  • 454
  • 2
  • 8
  • Please explain how this answers the question. A good answer should stand alone, even if the question is missing. – jpaugh Aug 15 '16 at 22:57
0

Some ways to redirect Page:

// Sets the new location of the current window.

window.location = "http://www.google.com";

// Sets the new href (URL) for the current window.

window.location.href = "http://www.google.com";

// Assigns a new URL to the current window.

window.location.assign("http://www.google.com");

// Replaces the location of the current window with the new one.

window.location.replace("http://www.google.com");
Nihar Sarkar
  • 1,187
  • 1
  • 13
  • 26