我的ajax调用正在传递以下数据:
var quoteParams ={check:true,startDate:date}
$.ajax({
type: "POST",
url: "check/save",
data: {orderForm : gatherOrderDetails(), quoteForm : quoteParams } , // GatherORderDetails will get all the form input values from a form
success: function(msg) {
alert(msg.d);
},
error: function(msg) {
alert('error');
}
});
因此,在我的控制器中,我希望获得“订单”#39;和' quoteForm'作为class的对象。该类是 Class orderssForm和Class quotesForm
def save(ordersForm orderForm,quotesForm quoteForm){
//now i need to save all the details obtained from 'orderform' and 'quoteform' after procerssing them in database.
}
但是我得到了参数无效的错误。
答案 0 :(得分:1)
只需定义您的保存操作:
def save() {
// do stuff with orderForm
params.orderForm
// do stuff with quoteForm
params.quoteForm
}
另请参阅data binding,它可以大规模简化事物的持久性。
不确定您的javascript gatherOrderDetails()函数正在执行什么操作,但如果您只需要提交所有表单元素,则可以使用serialize,例如
var data = $('form').serialize();
答案 1 :(得分:0)
我说,你应该通过request.JSON
def save() {
def json = request.JSON
doSomething json.orderForm
doSomethingElse json.quoteForm
}