Try to make a call to a method in my controller that will essentially render the page I am on so that updates are displayed. What do I need to add to my ajax call to call the grails method?
My desired flow is:
- On view roster
- Select check boxes, hit actionSubmit, onclick go to JS function that has an ajax call to a method in my controller.
- The call at my controller, updateInformation, will update all selected people
- After the call, I want to update my view roster. (currently the flow
ends after JS call)
roster.gsp:
$.ajax({
url: "updateInformation",
type:"GET",
data:{ids:JSON.stringify(idList), option:option, id:id}
});
I want to call in Controller:
def roster() {
[render stuff]
}
def updateInformation() {
... stuff ...
}
grails resolve the mapping by url path by default, so the follow should get the your controller.action once you replace it to your controller and action name:
Also, if you are using grails2 below, your controller action should be a closure:
If you don’t want to change the call, the original example will be calling the
updateNumberscontroller default action.If you want to map the original call to
updateNumbers.viewPage, you can set the default action toviewPagelike thisstatic defaultAction = "viewPage"in youupdateNumberscontroller.