Possible Duplicate:
pass parameter in g:remoteLink as result of javascript function
I am trying to call a remoteFunction call that is triggered by an onclick for a button, but the click does not call the function. I have tested the onlick command with an alert startment and the function is called. here is my code.
<input type="button" onclick="exportList()" value= "Export"/>
function exportList(){
var profile= document.getElementById('dropdown').value
${remoteFunction(controller: 'profile' , action:'export', params: "'profile=' + profile")}
}
When I take out the parameter and the var profile, the function is STILL not called... My controller and action are properly named so I do not know why I am having this error. Thanks in advance if you can help!
JoeCortopassi is correct - you can't just use the grails construct of ${remoteFunction...}
directly in javascript. I've done this using Jquery like this:
function exportList() {
var profileToUse = document.getElementById('dropdown').value
jQuery.ajax({
url: "/youApp/profile/export",
type: "POST",
data: {profile: profileToUse}
});
}
I don't know what this is supposed to do, but it looks poorly formed
${remoteFunction(controller: 'profile' , action:'export', params: "'profile=' + profile")}
are you sure you want to say var{remoteFunction()}
? Cause $
is just a variable. Makes even less sense if you are using jQuery. Also, what you are passing remoteFunction()
looks like it was supposed to be object, but isn't wrapped in {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With