When I tried to set a variable from javascript function in GSP view I had error: "Cannot invoke method func() on null object"
GSP:
<g:set var="variable" value="${tr.func.name()}" />
I also tried to the get around the problem without success: variable is undifined
<g:javascript>var test = tr.func.name();</g:javascript>
<g:set var="variable" value="${test}" />
<g:javascript>alert(${variable});</g:javascript>
Thanks
You should use Javascript in browser. GSP works on server side.
Just pass date in GMT to browser, and apply formatting there. There is a good js library for Date formatting: moment.js
You can't do that. <g:set>
is used to set server-side variables within the GSP. Javascript is client-side.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.