Since g:remoteFunction is deprecated what should I use instead? And please give an example.
you should use your own javascript AJAX functions, as they provide way more flexibility
EXAMPLE
used to be:
<input type="button" value="go!" onclick="${g.remoteFunction( controller:'my', action:'go', params:[..] )}"/>
should be (for example in 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()"/>
Just to elaborate on Injecteers answer actually the data:{} is what is posting information to it so may clash with params:[..]} :
<g:javascript>
function go(){
var javaScriptVariable='123'
$.ajax({
url:'${g.createLink( controller:'my', action:'go')}',
data:{
param1: "${params.params1}",
param2: javascriptVariable
}
});
}
</g:javascript>
data:{}
can also be data: $('form').serialize();
where serialize function grabs all the form elements and serializes it for you as params to be passed back.