i have this ajax code (with codeigniter framework)
function api_voiture_update(func_success, data, voiture_id, num, nom, prenom, entite, direction, immatriculation, marque, modele, finition, segment, boite, loueur, forfaitkm, duree, datedebut, datefin, ct, alerte, emissionsco2, etiquetteco2, consokm, couleur,gps , puissancech, cvfiscaux, energie, categorie, classe, telepeage, cartec, cartetotal, km, date, email_c, dateaffec, telephone, tco, tcoreel, tvs, pneuete, pneuhiver, loyermen, maintenance, pneu, loyerttc, amortissement, prixttc, prixoption, prixremise, optionre, remise, bonus, prixtotal, prixenergie, assurance, renonciation, avtnature, daterea, nomrea, comrea, couttotal, carbuanuel, comsuivi, comoption, alertect, checkct, checktotal, checktele) {
var options = {token: user.token, voiture_id: voiture_id, num: num, nom: nom, prenom: prenom, entite: entite, direction: direction, immatriculation: immatriculation, marque: marque, modele: modele, finition: finition, segment: segment, boite: boite, loueur: loueur, forfaitkm: forfaitkm, duree: duree, datedebut: datedebut, datefin: datefin, ct: ct, alerte: alerte, emissionsco2: emissionsco2, etiquetteco2: etiquetteco2, consokm, couleur: couleur, gps: gps, puissancech: puissancech, cvfiscaux: cvfiscaux, energie: energie, categorie: categorie, classe: classe, telepeage: telepeage, cartec: cartec, cartetotal: cartetotal, km: km, date: date, email_c: email_c, dateaffec: dateaffec, telephone: telephone, tco: tco, tcoreel: tcoreel, tvs: tvs, pneuete: pneuete, pneuhiver: pneuhiver, loyermen: loyermen, maintenance: maintenance, pneu: pneu, loyerttc: loyerttc, amortissement: amortissement, prixttc: prixttc, prixoption: prixoption, prixremise: prixremise, optionre: optionre, remise: remise, bonus: bonus, prixtotal: prixtotal, prixenergie: prixenergie, assurance: assurance, renonciation: renonciation, avtnature: avtnature, daterea: daterea, nomrea: nomrea, comrea: comrea, couttotal: couttotal, carbuanuel: carbuanuel, comsuivi: comsuivi, comoption: comoption, alertect: alertect, checkct: checkct, checktotal: checktotal, checktele: checktotal, ids: user.ids, statu: user.statu};
var data2 = $.extend({}, data, options);
alert(JSON.stringify(data2));
$.ajax({
type: "POST",
url: base_url + 'voiture/update',
data: data2,
error: function(data) {
error = $.parseJSON(data.responseText).error;
func_error(error);
},
success: function(data)
{
alert(JSON.stringify(data));
if (data.length === 0)
alert("Les modifications n'ont pas été prises en compte, veuillez recommencer.");
console.log(data);
func_success(data);
}
});
}
data of the extend is a getFormData of my form. The problem is that, with the alert of data2, array isn't empty, but with the alert of data, it is empty. But data = data2, so i don't understand.
And, in more, this bug doesn't come all the time, one time it work, data isn't empty, and the other time, it fail.
Thanks for your read.