My websites signup for script is below. When a user clicks signup, it sends all the data to another page through AJAX, if it is successful, it is supposed to change the page, however, it seems as soon as I call the function, the page reloads to the homepage with top.location.href = '/';
instead of waiting for success of the AJAX call.
What am I doing wrong and how could I fix it?
<script>
$("#button").click(function() {
username = $('#loginNames').val();
password = $('#passwords').val();
email = $('#email').val();
q = $('#q').val();
a = $('#a').val();
name = $('#i7').val();
jQuery.ajax({
type: "POST",
url: "signupprocess.php",
data: {'username':username, 'password': password, 'email': email, 'q':q, 'a':a, 'name': name},
cache: false,
success: function(response) {
if(response === up) {
top.location.href = '/';
} else {
$('#response').html(response);
}
}
});
return false;
});
</script>