App info:
- Grails 3.1.8
- Jquery 2.2.0
I have a Grails form which I would like to POST via AJAX. I am able to do this and the data does persist in the database. Code to post is below:
<g:javascript>
$('#insertSchool').submit(function () {
$.ajax({
type: 'POST',
url: '/school/saveSchool',
data: $("#insertSchool").serialize(),
success: function(savedSchool) {
}
});
});
</g:javascript>
Controller code:
def saveSchool(School newSchool) {
def theSchool = schoolService.saveSchool(newSchool)
render theSchool as JSON
}
In the success function I would like to redirect to another page and send a message across saying the school has been saved. I'm new to Jquery so I'm unable to implement this. Any help would be appreciated.