Since g: remoteFunction in Grails 2.4.X is deprecated, what should I use instead?

Since g: remoteFunction is deprecated, what should I use instead? And please give an example.

+4
source share
2 answers

you should use your own javascript ajax functions as they provide more flexibility

Example

:

<input type="button" value="go!" onclick="${g.remoteFunction( controller:'my', action:'go', params:[..] )}"/>

should be (e.g. c JQuery):

<g:javascript>
  function go(){
    $.ajax({ 
      url:'${g.createLink( controller:'my', action:'go', params:[..] )}',
      data:{ param1:param1 }
    });
  }
 </g:javascript>

 <input type="button" value="go!" onclick="go()"/>
+4
source

Just in order to tell in detail about the injectors, the data actually responds: {} is what sends information to it, therefore it may encounter parameters: [..]}:

<g:javascript>
  function go(){
   var javaScriptVariable='123'
    $.ajax({ 
      url:'${g.createLink( controller:'my', action:'go')}',
      data:{ 
        param1: "${params.params1}",
        param2: javascriptVariable 
      }
    });
  }
 </g:javascript>

data:{} data: $('form').serialize();, , .

0

All Articles