When working in a Grails view, I find myself needing to execute a JavaScript method to retrieve certain information. To achieve this, I have set up a submit action as shown below:
<input type="submit" name="submit" class="submit action-button" value="Generate" onclick="generateReport()" style="float: right" />
After the generateReport()
function is executed, I need to call or redirect to the show
action of a Controller (since I am already at the create
action).
I have attempted two approaches:
1) var jsonData = generateJSON();
<g:remoteFunction controller="report" action="show" params="[data:jsonData]" />
2) var jsonData = generateJSON();
<g:remoteFunction controller="report" action="show" params="[data:${jsonData}]" />
The issues encountered were:
1) The data passed was null.
2) A compilation error occurred:</p>
<code>org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
Message
Attribute value quote wasn't closed (controller="report" action="show" params="[data:${jsonData}]").