
14/10/2013, 09:52
|
| | Fecha de Ingreso: octubre-2013
Mensajes: 3
Antigüedad: 11 años, 6 meses Puntos: 0 | |
Controlador recibe un arreglo vacio desde js Buenas foreros, mi problema es el siguiente, tengo 7 arreglos que me almacenan 4 horarios cada uno (dos entradas y dos salidas), la cosa es que me envía los arreglos vacíos, pero el problema parece ser los arreglos y no la data dentro de ellos ya que haciendo un alert($('#lh1M').val()) me retorna el valor que introduzco por el formulario pero haciendo un alert(lunesm) me retorna vació en ambas posiciones.
aqui les dejo el codigo a ver si me pueden ayudar
Código:
function editar(){
$('#Editar').dialog({
autoOpen: false,
height: 660,
width: 900,
modal: true
});
$('.editar').on('click',function(){
$('#Editar').dialog('open');
var valores = this.value;
valores = valores.split(',');
/*dumpVars(valores);*/
$('#idM').val(valores[0]);
$('#nombreM').val(valores[1]);
// alert(valores[4]);
if (valores[2]==1){
$("#gerencialM:checkbox").attr("checked","checked");
}else{
$("#gerencialM:checkbox:checked").removeAttr("checked");
}
// /*alert($('#lh1M').val());
// dumpVars($('#lh1M').val());*/
// //variable = $("#lh1M").val();
// //$('#lh1M').val();
var arrLunes = new Array();
$('#lh1M').val( (valores[3]=='00:00:00')?'':valores[3] );
$('#lh2M').val( (valores[4]=='00:00:00')?'':valores[4] );
$('#lh3M').val( (valores[5]=='00:00:00')?'':valores[5] );
$('#lh4M').val( (valores[6]=='00:00:00')?'':valores[6] );
arrLunes[0] = new Array( $('#lh1M').val(),$('#lh2M').val());
arrLunes[1] = new Array( $('#lh3M').val(),$('#lh4M').val());
var lunesm = arrLunes;
var arrMartes = new Array();
$('#mh1M').val( (valores[7]=='00:00:00')?'':valores[7] );
$('#mh2M').val( (valores[8]=='00:00:00')?'':valores[8] );
$('#mh3M').val( (valores[9]=='00:00:00')?'':valores[9] );
$('#mh4M').val( (valores[10]=='00:00:00')?'':valores[10] );
arrMartes[0] = new Array( $('#mh1M').val(),$('#mh2M').val());
arrMartes[1] = new Array( $('#mh3M').val(),$('#mh4M').val());
var martesm = arrMartes;
var arrMiercoles = new Array();
$('#mmh1M').val( (valores[11]=='00:00:00')?'':valores[11] );
$('#mmh2M').val( (valores[12]=='00:00:00')?'':valores[12] );
$('#mmh3M').val( (valores[13]=='00:00:00')?'':valores[13] );
$('#mmh4M').val( (valores[14]=='00:00:00')?'':valores[14] );
arrMiercoles[0] = new Array( $('#mmh1M').val(),$('#mmh2M').val());
arrMiercoles[1] = new Array( $('#mmh3M').val(),$('#mmh4M').val());
var miercolesm = arrMiercoles;
var arrJueves = new Array();
$('#jh1M').val( (valores[15]=='00:00:00')?'':valores[15] );
$('#jh2M').val( (valores[16]=='00:00:00')?'':valores[16] );
$('#jh3M').val( (valores[17]=='00:00:00')?'':valores[17] );
$('#jh4M').val( (valores[18]=='00:00:00')?'':valores[18] );
arrJueves[0] = new Array( $('#jh1M').val(),$('#jh2M').val());
arrJueves[1] = new Array( $('#jh3M').val(),$('#jh4M').val());
var juevesm = arrJueves;
var arrViernes = new Array();
$('#vh1M').val( (valores[19]=='00:00:00')?'':valores[19] );
$('#vh2M').val( (valores[20]=='00:00:00')?'':valores[20] );
$('#vh3M').val( (valores[21]=='00:00:00')?'':valores[21] );
$('#vh4M').val( (valores[22]=='00:00:00')?'':valores[22] );
arrViernes[0] = new Array($('#vh1M').val(),$('#vh2M').val());
arrViernes[1] = new Array($('#vh3M').val(),$('#vh4M').val());
var viernesm = arrViernes;
var arrSabado = new Array();
$('#sh1M').val( (valores[23]=='00:00:00')?'':valores[23] );
$('#sh2M').val( (valores[24]=='00:00:00')?'':valores[24] );
$('#sh3M').val( (valores[25]=='00:00:00')?'':valores[25] );
$('#sh4M').val( (valores[26]=='00:00:00')?'':valores[26] );
arrSabado[0] = new Array($('#sh1M').val(),$('#sh2M').val());
arrSabado[1] = new Array($('#sh3M').val(),$('#sh4M').val());
var sabadom = arrSabado;
var arrDomingo = new Array();
$('#dh1M').val( (valores[27]=='00:00:00')?'':valores[27] );
$('#dh2M').val( (valores[28]=='00:00:00')?'':valores[28] );
$('#dh3M').val( (valores[29]=='00:00:00')?'':valores[29] );
$('#dh4M').val( (valores[30]=='00:00:00')?'':valores[30] );
arrDomingo[0] = new Array($('#dh1M').val(),$('#dh2M').val());
arrDomingo[1] = new Array($('#dh3M').val(),$('#dh4M').val());
var domingom = arrDomingo;
$("#frmEditarHorarios").validate({
rules:{
idM:{required:true,maxlength:20},
nombreM:{required:true,maxlength:50}
},
messages:{
idM:{required:"Campo obligatorio",maxlength:"Longitud excedida. Maximo 20 caracteres"},
nombreM:{required:"Campo obligatorio",maxlength:"Longitud excedida. Maximo 50 caracteres"}
},
errorElement: "div",
submitHandler: function(){
dumpVars(lunesm);
$("#CargandoGif").show();
$.ajax({
type:"post",
dataType:"json",
url:"index.php",
data:{ m_modulo:"horarios",
m_accion:"editar",
m_vista:"editado",
m_formato:"json",
idm : $("#idM").val(),
nombrem : $("#nombreM").val(),
gerencialm : ($("#gerencialM").is(':checked')?1:0),
lunes : lunesm,
martes : martesm,
miercoles : miercolesm,
jueves : juevesm,
viernes : viernesm,
sabado : sabadom,
domingo : domingom
},
success: function(datos, textStatus, jqXHR ){
//1= se ejecutó el DML correctamente
if (datos==1){
$('#CargandoGif').hide();
alert("Horario editado con éxito");
location.reload();
}else{
$('#CargandoGif').hide();
alert("Error al editar el Horario");
}
},
error: function(datos, textStatus, jqXHR ){
$('#CargandoGif').hide();
alert("error al procesar la petición: " + datos);
}
});
}
});
});
}
|