[jQuery] jQuery.post -> PHP script -> redirect
Hi All,
I have following problem:
I would like to post (jQuery.post) login-form variables to the PHP
script ("backend.php") for validation and if it is succesfull then
redirect to "myaccount.php".
Here is my code:
<script type="text/javascript">
$(document).ready(function() {
$("#submit_butt").click( function() {
// configurations for the buzzing effect. Be careful not to make it
too annoying!
var conf = {
frequency: 5000,
spread: 5,
duration: 600
};
/* do your AJAX call and processing here...
.... */
var unameval = $("#username").val();
var pwdval = $("#pwd").val();
//alert(unameval+pwordval);
$.post("backend.php", { username: unameval, pwd: pwdval }, function
(data){
if(data.length >0) {
window.location.href("account.php");
}
});
// this is the call we make when the AJAX callback function
indicates a login failure
$("#login").vibrate(conf);
// let's also display a notification
if($("#errormsg").text() == "")
$("#loginform").append('<p id="errormsg">Nesprávne meno alebo heslo!
');
// clear the fields to discourage brute forcing :)
$("#username").val("");
$("#pwd").val("");
});
});
</script>
Can you help me? Any suggestions???
Thank you very much for your response....
Best,
Marian