[jQuery] jQuery.post -> PHP script -> redirect
Hi All,
I am looking for the solution of this problem:
i have a login form. i would like to "shake" the login-form box, if
the authentication (PHP+MySQL) failed.
i use jQuery.post for posting the values from login form to the PHP-
script (used for validation - named "backend.php").
This is the 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();
$.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>
Could you pls help me? Any suggestions?
Thanks a lot.
Best,
Marian