0
votes

I've got a function that creates my data object:

var data={
    id:1,
    answers:[]
}

$.each($('.panel-body input[type="text"'), function(k,v) {
    data.answers.push( $(v).val() );
});

This data object will be asserted to the data-attribute in the jQuery ajax section. The console.log of data will output this:

Object {id: 1, answers: Array[2]}answers: Array[2]0: "test1"1: "test2"length: 2__proto__: Array[0]id: 1 }

The problem is that I don't know how to access the answers array in Grails.

println params in my Grails controller will output

[id:1, answers[]:[test1, test2]]

println params.id will print 1 but println answers[] results in null. How can I access? Thank you.

1

1 Answers

0
votes

Please try accessing it via

params.list('answers[]')