Getting javaScript data send with ajax with Playframework2 DynamicForm object. Error: data={data[undefined]=}

64 views Asked by At

I am sending Javascript array with ajax using post method like this:

$.post(assignmentsubmitAddress, submittedUnitsArray, 

In returning I am getting status OK.

But when I wonna retrieve that data on server with PlayFramework2 Dynamic form object like this:

DynamicForm requestData = form().bindFromRequest();
System.out.println(requestData.toString());

I am getting in console:

Form(of=class play.data.DynamicForm$Dynamic, data={data[undefined]=}, value=Some(Form.Dynamic({undefined=})), errors={})

Why I'm getting this:

data={data[undefined]=}

How can I prepare java script data to be readed with play dynamic form?

How to read java script array in playframework?

1

There are 1 answers

0
masterdany88 On

The java script array list variable submittedUnitsArray is correct.

BUT It should be passed to ajax posting function this way:

$.post(assignmentsubmitAddress, { 'activitiesArray' : submittedUnitsArray },

Now it works.