I am trying to redirect in one of program but failed.I tried making a simple program where on a click of submit button it should redirect to another page. I must be making some very fundamental mistake but could not get it figured out.
I have a simple page where a form is created with an input box and submit button. On click of button a jquery is invoked which just redirect it to another page.
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
 <h1>Testing Redirection in Jquery</h1>
 <form method="POST" id="redirectForm" name="redirectForm">
  <input type="text" id="extraField" name="extraField"/><br/><br/>
  <input type="submit" value="Submit" id="btnSubmit" name="btnSubmit" />
 </form>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"> 
 </script>
 <script>
  $(document).ready(function () {
   $("#btnSubmit").click(function (e) {
     alert("Start");
     var extraField = document.getElementById("extraField").value;
     try { 
       window.location.replace("page2.php"); 
       console.log("Successful");
     } 
     catch(e) { 
       window.location = "page2.php";
       console.log("Failed");                   
     }
    });
   });
 </script>
</body>
</html>
It just failed to redirect to page2.php rather it remains on the same page. I put the console.log as well it shows successful for a second and goes away. It shows no error as such.
Please help me to figure out the problem.
 
    