This is my ajax call: <body onload = "${remoteFunction(controller:'accountManagement', action:'createAccount',
params:[facebookUID: params.facebookUID, gender: params.gender, firstName: params.firstName, lastName: params.lastName])}">
In my controller I have a redirect instruction at the end:
def createAccount = {
if(user.save(flush:true) == null){
...
}
else{
....
for(int i = 0; i < categories.length; i++){
...
}
println "save to database: successful"
}
// Redirect to index action of person controller.
redirect(controller:'user', action: 'authenticate');
}
`
It does not redirect. Instead, it stays on the same loading page that it started on.
Browsers won’t redirect if an AJAX call returns a redirect. If you want to send the user to a new page after an AJAX call, you’ll need to do so yourself in Javascript. Example:
Ensure the AJAX response gets rendered by the browser. With the grails
remoteFunctiontag you should specify an element to update with theupdateattribute.