jquery - How can I render a grails model to javascript using a post method from a controller action? -


at jquery event want call upon controller action , use data. way did until was:

$('#my-button').click(function(){ $.post("${createlink(controller: 'myview', action: 'myaction')}", {param1: x, param2: y}, function(data){     //in here want use both elements of model see fit. })  }); 

my controller method looks this:

def myaction(param1, param2){ //some data manipulation goes here  render model: [returnvalue1: variable1, returnvalue2: variable2]; } 

my question how can access variable1 , variable2 $.post method? if don't use model , return 1 of variables, data equal variable, in case won't.

can tell me how access variables in model please? calling ${returnvalue1} not work in function.

you can render json object representing model. here's render documentation

render(contenttype: "text/json") {     [returnvalue1: variable1, returnvalue2: variable2] } 

or

render([returnvalue1: variable1, returnvalue2: variable2] json) 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -