I am using the new HTML5 FormData-Object to post some values and an image via Ajax. It works fine so far. Now, I want to post an array using this object, but all I´ve got on server-side is "[object - object]". How can I post an array with formdata?
What I´ve got so far
var formData=new FormData();
formData.append('text', $('#text').attr('value'));
formData.append('headline',$('#headline').attr('value'));
formData.append('myarray',{key1: 'bla', key2: 'blubb'});
The last line doesn´t work. I send the request with this code
$.ajax({
url: 'xyz',
data: formData,
type: 'POST',
processData: false,
contentType: false,
success: function(data) {
var decoded=$.parseJSON(data);
displaySuccess('Success', decoded.message);
},error: function(data){
var decoded=$.parseJSON(data);
displayError('Error', decoded.message);
},complete: function(data){
$('#cursor').hide();
$("#submitbutton").removeAttr('disabled')
}
});
Thanks in advance.