Prabin Poudel Prabin Poudel - 1 month ago 12
Javascript Question

Using Ajax call params in Controller

my ajax call is passing following data:

var quoteParams ={check:true,startDate:date}
type: "POST",
url: "check/save",
data: {orderForm : gatherOrderDetails(), quoteForm : quoteParams } , // GatherORderDetails will get all the form input values from a form

success: function(msg) {
error: function(msg) {


So in my controller i want to get the 'orderform' and ' quoteForm' as object of class.the class are Class orderssForm and 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.


But i get error that the params is invalid.

Answer Source

Just define your save action like this:

def save() {
    // do stuff with orderForm

    // do stuff with quoteForm

Also take a look at data binding which can massively simplify the persistence side of things.

Not sure what your javascript gatherOrderDetails() function is doing but if you just need to submit all form elements you can use serialize e.g.

var data = $('form').serialize();