I am new to javascript and jquery and need your help out. I have tried searching the forums but I was unable to find a solution
i am trying to post something to a php file and then redirect to a page of my choice. The post is happening properly but not the redirect.
The html form is
<form action="userinfo.php" method="post">
<p><input type="text" required maxlength=7 name="login" id="login" value="" placeholder="Username"></p>
<p><input type="password" required name="password" id="password" value="" placeholder="Password"></p>
<p class="remember_me">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
Remember me on this computer
</label>
</p>
<p class="submit"><input type="button" id="searchForm" onclick="SubmitForm();redirect()" value="Login"></p>
</form>
and the jquery code is
<script>
function SubmitForm() {
var login = $("#login").val();
var password = $("#password").val();
$.post("userinfo.php", {login: login, password: password },
function(data) {
alert("Data Loaded: " + data);
});
}
function redirect(){
alert("Redirecting..");
window.location = "mainpage.html"
}
</script>
SO redirect() is obviously not being called.Any help as to why this is happening is appreciated. Please note that i am not a javascript or jquery expert. Just trying my luck to learn something.. :-)
p.s: I can redirect from the php file but wouldn't prefer to do that.