When susseccsully signing into my account on my website I am trying to open another html page a.k.a home.html.
I have tried using a href to redirect to see if it opens my html file. I also did a window.location.href(javascript) after I sign in to open the home.html file. Both give me 404’s This is the code im using.
<head>
<title>Login - Storm Shooter</title>
<link rel="icon" type="image/x-icon" href="SS Image.ico">
</head>
<body>
<a href="home.html">Home</a>
<h1>Sign Up</h1>
<form id="signup">
<input id="uname1"></input>
<input type="password" id="pswd1"></input>
<button id="submit">Submit</button>
</form>
<h1>Log In</h1>
<form id="login">
<input id="uname2"></input>
<input type="password" id="pswd2"></input>
<button id="submit">Submit</button>
</form>
</body>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
$("#login").submit(function(e){
e.preventDefault()
$.post("/login",{uname:$("#uname2").val(),pswd:$("#pswd2").val()}, function(data, status) {
if(data=="success") {
alert('Success!');
window.location.href = "home.html";
} else {
alert("Login failed");
}
});
});
$("#signup").submit(function(e){
e.preventDefault()
$.post("/signup",{uname:$("#uname1").val(),pswd:$("#pswd1").val()}, function(data, status) {
if(data=="success") {
alert('Success!');
window.location.href = "home.html";
} else {
alert("Login failed");
}
});
});
</script>