Reputation: 2010
I have a Groovy/Grails project with a view that has some data rendered to it from its controller, say the controller is called MyController and the data I want to render is called ${myData}. The relevant part of my view looks like this:
<head>
$('#refreshData').click(function(){
//here I want to run the method in my controller and update the value of myData
});
...
</head>
<body>
...
<input type="text" id="inputData" />
<button id="refreshData">Submit</button>
...
</body>
My controller has an action that receives an argument of type String (it's supposed to receive it from the input form)
def updateData(String input) {
//updating input
[myData: return_value]
}
I want to call the action updateData from my jquery function either by having a local js variable assigned with the return value of that function or by having a variable rendered to my view and accessing it. I tried calling
var newData = ${
remoteFunction(
controller: 'my',
action: 'updateData',
params =[string_from_form]
)};
but I am getting the error groovy.lang.MissingMethodException
with a message of the form
No signature of method <> is applicable for values (java.util.LinkedHashMap, java.util.ArrayList) values: [[controller:my...
Can somebody please tell me how to call the controller method with my parameter from that jQuery function?
Upvotes: 1
Views: 9067
Reputation: 2880
Looks like you might have a bug in the params section of your code. Try:
var newData = ${remoteFunction(controller: 'my', action: 'updateData', params: '[string_from_form]')};
Upvotes: 2