I'm doing a sales system in php and mysql. The database operations I do with jquery ajax. I save header and detail of the sale separately, the detail is shown in a grid of jqwidgets from which I extract its datasource in as an object of arrays. Where each array of the object is a column of the grid. My question is how to get the values of those arrays to save them, because until now I only insert null fields in the bd. This is the code:
var i = 0;
while(dataGrilla[i]){
for(var arreglo in dataGrilla) {
for(var elemento in dataGrilla[arreglo]){
//console.log(elemento);
cod_det = dataGrilla['colcodigos'];
p_unit = dataGrilla['colprecio'];
cantidad = dataGrilla['colcantidad'];
}
grabaDetServ();
}
i++;
}
function grabaDetServ() {
var action = 'grabaDet';
var recargo = 0;
var folio3 = folio;
$.ajax({
type: 'GET',
data: {action: action,cod_sec:cod_sec,cod_det:cod_det,p_unit:p_unit,cantidad:cantidad,folio:folio3},
url: '../app/venta.php',
success: function () {
//toastr.success('Detalle guardado ok');
},
error: function () {
toastr.error('Error al guardar detalle');
}
});
}
the data I want to get out of the array are: cod_det, p_unit and quantity, the others are fixed.