I need to send some data using ajax and FormData, because I want to send a file and some other parameters. I usually send data:
$.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 do not use FormData (), I have no problem, but when using FormData () only the data on Lvl1 is fine, but something nested is displayed as a 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 data inside Lvl1-3 instead of [object Object] , I get [object FormData]
How do I get an array instead of a string on Lvl1-3?
NOTE. If the file is at the top level (Lvl_1), I can send the file without problems using FormData (). I did not write the code of the attached file, because this is not a problem, the attached data. I just mentioned the file because because I use FormData ().
source share