I want to send some JS Script from controller to GSP view . I do the following attempt.
Controller(Purchase.groovy) :
def myaction={
flash.script= 'jQuery("div#header").show(1000);'
redirect(action:'edit')
}
In purchase/myaction.gsp file, I try the following code
<g:if test="${flash.script !=null}">
<g:javascript>
$(function() {
${flash.script}
})
</g:javascript>
</g:if>
<g:else>
<g:javascript>
$(function() {
alert('Welcome')
})
</g:javascript>
</g:else>
I try also : jQuery.getScript('${flash.script}') instead of '${flash.script}'
However, GSP page renders always the second script(else statement)