I am loading the contents of several select with ajax, everything works fine when I execute one by one, but when nesting it executes the ajax but does not take the refreshed value, that is, I have three select and I wish that when executing the ajax of the first select update to the second select and update this run a second ajax and this update the third select, I leave my code that is almost ok because it does not take the value shown:
<select name="tipdoc" id="tipdoc" onchange="traerccp(this.value);">
<option value="FAC">FACTURA</option>
<option value="BOL">BOLETA</option>
</select>
<select name="concepto" id="concepto" onchange="traerser(this.value);">
<option value="VTA">VENTA</option>
</select>
<select name="serie" id="serie">
<option value="1">1</option>
</select>
these are the three selections which are nested and each has a function with ajax that updates the other, I show the code in js:
//llamo a los conceptos según el tipo de documento escogido function traerccp(tido){ var empr = $("#empresa").val(); var parametros = { "empr" : empr, "tido" : tido}; $.ajax({ data: parametros, url: '?accion=traerconcepto', type: 'post', dataType: "html", success: function (response) { $("#concepto").html(response); } }); // hasta aquí todo bien, hasta cambia los valores en select concepto, pero en // la siguiente linea de código el valor de concepto no cambio, es decir se // quedo con el valor "VTA" y al llamar la funcion de traer las series // tambien con ajax el resultado es erroneo traerdoc($("#concepto").val());} function traerser(ccep){ var empr = $("#empresa").val(); var tido = $("#tipdoc").val(); var parametros = { "tido" : tido, "ccep" : ccep, "empr" : empr}; $.ajax({ data: parametros, url: '?accion=traerserie', type: 'post', dataType: "html", success: function (response) { $("#serie").html(response); } });}
I await your comments thank you.