I have a piece of code which goes as following:
var o_titular = {id:'01',fecha:'2014-01-01'};
var o_dependientes = [
{id:'02',fecha:'2014-02-02'},
{id:'03',fecha:'2014-03-03'}
];
var o_fecha = '2014-05-05';
$("#documento-antiguedad").ajaxSubmit({
dataType: 'json',
data: {
titular: o_titular,
dependientes: o_dependientes,
fecha: o_fecha
},
success: function(r) {
alert("yay success");
}
});
I'm forced to make this ajaxSubmit (this is a simplified code, but the complete case involves file uploading and such) but when I see the data I send in the POST request i got the following:
titular [object Object]
dependientes [object Object],[object Object]
fecha 2014-05-05
of course I want to fiddle with the content of the objects, not the object itself. How can I send this parameters as JSON objects with ajaxSubmit?
Thank you in advance
EDIT:
When I make a regular ajax call:
var o_titular = {id:'01',fecha:'2014-01-01'};
var o_dependientes = [
{id:'02',fecha:'2014-02-02'},
{id:'03',fecha:'2014-03-03'}
];
var o_fecha = '2014-05-05';
$.ajax({
url:'/pendientes/index/creatependienteantiguedad/',
dataType: 'json',
data: {
titular: o_titular,
dependientes: o_dependientes,
fecha: o_fecha
},
success: function(r) {
alert("yay success");
}
});
I get the following:
dependientes[0][fecha] 2014-02-02
dependientes[0][id] 02
dependientes[1][fecha] 2014-03-03
dependientes[1][id] 03
fecha 2014-05-05
titular[fecha] 2014-01-01
titular[id] 01
That's exactly what I want to get, but with ajaxSubmit instead of Ajax.