Hi, I have a basic sign up form and my javascript is as follow:
$("#signUpButton").click(function() {
var confirmation = $('#rform-confirmation').is(':checked');
//console.log(confirmation);
if(confirmation) {
var firstname = $("#rform-firstname").val();
var lastname = $('#rform-lastname').val();
var email = $('#rform-email').val();
var password = $('#rform-password').val();
var rpassword = $('#rform-rpassword').val();
var tokenKey = $('#rform-csrf').attr('name');
var token = $('#rform-csrf').val();
console.log(tokenKey);
console.log(token);
//debugger;
$.ajax({
url: '/register/doRegister',
type: 'POST',
data:{
firstname: firstname,
lastname: lastname,
email: email,
password: password,
rpassword: rpassword,
tokenKey: tokenKey,
token: token
},
success: function(res) {
console.log(res);
}
});
} else {
alert('Please agree to the Terms of Service.');
return false;
}
});
Now I have this in my controller:
$send = $user->addUser($email, $pwd, $fname, $lname);
if($send){
$this->flash->success('You have registered successfully');
$this->response->redirect('/signin');
}
The functionality works fine (ie. it saves into the model and everything else) but it just reloads the page and somehow I can see that in the url bar in the browser shows the information of the POST. The flash message will come after I physically clicked on another link. I tried doing different redirect path in $this->response->redirect('signin');
or $this->response->redirect($this->get->url('signin');
still does not work. Though if I use the same redirection in other function they work perfectly.