I need to send some data using ajax and FormData, because I want to send a file and some other parameters. The way I usually send data is this:
$.ajax({
type: 'POST',
url: 'some_url',
dataType: 'json',
processData:false,
contentType:false,
data:{
Lvl_1-1: 'something',
Lvl_1-2: 'something',
Lvl_1-3: {
Lvl_1-3-1: "something",
Lvl_1-3-2: "something",
Lvl_1-3-3: "something",
},
},
...
});
If I don't use FormData(), I have no problem, but when using FormData(), only the data on Lvl1 is ok, but anything nested is displayed as string like this
<b>array</b> <i>(size=3)</i>
'Lvl1-1' <font color='#888a85'>=></font> <small>string</small>
<font color='#cc0000'>'Something'</font>
<i>(length=23)</i>
'Lvl1-2' <font color='#888a85'>=></font> <small>string</small>
<font color='#cc0000'>''Something''</font> <i>(length=3)</i>
'Lvl1-3' <font color='#888a85'>=></font> <small>string</small>
<font color='#cc0000'>'[object Object]'</font> <i>(length=17)</i>
If I use FormData() to encode the data inside Lvl1-3, instead of [object Object]
I get [object FormData]
How do I get an array instead of string on Lvl1-3?
NOTE: If the file is on top level (Lvl_1) I can send the file with no problems using FormData(). I didn't wrote the code of the file attached because that's not the problem, nested data is. I just mentioned the file because that's why I'm using FormData().