I know this is a recurrent/classical topic but I did not found anything that helped me so far.
I am trying to render a Map from my controller. This results from an Ajax request and is supposed to be “eaten” by a Javascript function ‘onSuccess’.
Here is my Javascript and .gsp view:
<g:javascript>
function updateVideoLoad(e) {
var map = eval("("+e.responseText+")") // evaluate the JSON
$('#resultsChecker').html(map.urlAccepted + ' - ' + map.provider + ' - ' + map.videoId + ' - ' + map.videoTag)
}
</g:javascript>
<g:formRemote name="myForm" update="" url="[controller: 'project', action:'addVideo']" onSuccess="updateVideoLoad(e)">
...
</g:formRemote>
Here is my controller:
import grails.converters.JSON
class ProjectController {
def addVideo() {
...
def videoMap = [urlAccepted: videoList[0], provider: videoList[1], videoId: videoList[2], videoTag: videoList[3]]
render videoMap as JSON
}
It looks to me exactly as the example provided in the Grails documentation.
However it does not work. On the browser console, I get:
Uncaught ReferenceError: e is not defined
from my g:remoteForm.
Any suggestion is most welcome.
Thank you for your help.
This seems to be working:
Is there a place where to get documentation on those javascript events (
onComplete,onSuccess, …) ?