Good morning friends of this forum.
I have a problem, when executing a js instruction from a function that is executed with the onreadystatechange
of the ajax, whose purpose is to update the data of a form, some instructions are not executed. At first I thought it was a syntax error, however, the same instruction is executed from the browser console. This has led me to think that there are some limitations to the instructions that can be used from a function in ajax, in runtime.
If anyone knows anything about it, I appreciate the help. Next I copy the code:
xact.onreadystatechange = function() {
if(xact.readyState == 4 && xact.status == 200){
actDatos =xact.responseText;
actDatos = JSON.parse(actDatos);
buscarProvinciaEd(actDatos[0].pais);
buscarMunicipioEd(actDatos[0].estado);
candNombre.value = actDatos[0].nombre;
candDocIde.value = actDatos[0].docidentidad;
candFnac.value = actDatos[0].nacimiento;
candDirecc.value = actDatos[0].direccion;
candTelef.value = actDatos[0].telefono;
candMail.value = actDatos[0].email;
candAspSa.value = actDatos[0].salariopref;
candObjet.value = actDatos[0].objetivo;
//$("#cSexo option[value="+ actDatos[0].sexo +"]").attr("selected",true);
$("#cprofArea option[value="+ actDatos[0].rama +"]").attr("selected",true);
$("#cPais option[value="+ actDatos[0].pais +"]").attr("selected",true);
$("#cEstado option[value="+ actDatos[0].estado +"]").attr("selected",true);
$("#cMunicipio option[value="+ actDatos[0].municipio +"]").attr("selected",true);
candSexo.value = actDatos[0].sexo;
//candAreaP.value = actDatos[0].rama;
//candPais.value = actDatos[0].pais;
//candEstado.value = actDatos[0].estado;
//candMunici.value = actDatos[0].municipio;
}