ajaxgrailstaglibgrails3ajaxtags

How to use ajax in Grails 3.2.3


I worked in grails 2.4.7 .Recently i shifted to grails 3.Previously i used grails custom tag for ajax call like remoteFunction, formRemote .This tags are not available for recent version.Can any one tell me the best way of using ajax for recent version .


Solution

  • Yes, from onward 2.4.x g:remoteFunction has been deprecated in grails.

    See this. http://docs.grails.org/2.4.1/ref/Tags/remoteFunction.html

    Though, you can always use the javascript/jQuery ajax function as below which is exactly does the same thing.

    <g:javascript>
      function callMyAjax(){
        $.ajax({ 
          url:'${g.createLink( controller:'yourcontroller', action:'youraction')}',
          data:{ 
               param1:param1,
               param2:param2
          }
        });
      }
     </g:javascript>
    
     <input type="button" onclick="callMyAjax()"/>