I have this code, the animation happens but the redirect to the next page ( work.php
) does not.
That is, you are not entering the if (isset($_POST...
condition. If I comment on the piece of code responsible for the animation the redirection already happens, but that's not what I want:
index.php:
if (isset($_POST['submit'])) {
$firstName = htmlentities($_POST['name']);
$firstName = str_replace(array('.', ',', ';', '?', '/', '|', '(', ')', 'º', '+', '#', '$', '@', "'", '"'), '' , $firstName);
$firstName = trim(ucwords($firstName));
if(!empty($firstName)) {
$user->saveCookie($firstName);
}
header('Location: work.php');
}
require_once('includes/head.php');
?>
<body onunload="">
<div id="wrapper">
.....
<form action="" method="POST">
<input name="name" type="text" autocomplete="off">
<input type="submit" name="submit">
</form>
.....
</html>
js.js:
$('input[type="submit"]').click(function(event) {
event.preventDefault();
$('#footer').css({
"position":"absolute",
"bottom": "5px"
});
$('#wrapper').animate({
"margin-top": "-1000px"
}, 700, function(){
$('form').submit();
});
});