在 jquery 事件中,我想调用控制器操作并使用其数据。到目前为止,我这样做的方式是:
$('#my-button').click(function(){
$.post("${createLink(controller: 'myview', action: 'myAction')}", {param1: x, param2: y},
function(data){
//in here I want to use both elements of the model as I see fit.
})
});
我的控制器方法如下所示:
def myAction(param1, param2){
//some data manipulation goes here
render model: [returnValue1: variable1, returnValue2: variable2];
}
我的问题是如何从我的 $.post 方法访问 variable1 和 variable2?如果我不使用模型而只返回其中一个变量,数据将完全等于该变量,但在这种情况下它不会。
谁能告诉我如何访问该模型中的这些变量?仅调用 ${returnValue1} 在该函数中不起作用。