I make a first Ajax request to which I nest a second and later I nest another one. All three do the same type of operation and the code is exactly the same except that other variables are used. They make the request to the same page and execute the same web method on it. This method has six parameters. I see debugging that the first request is executed, but the next two are not. I can't find the reason since the action they perform is identical and the structure of the request is the same, only that the second is nested to the first and the third to the second.
What I would like is to find out what aspect of my code structure of the three requests is wrong so that the two nested requests do not execute. Variables passed in requests have a checked value. I don't want you to examine the code conceptually, I'd just appreciate a syntax review.
My code is the following:
$.ajax({
type: "POST",
url: "Respuestaajax.aspx/Respuestaaj",
contentType: "application/json; charset=utf-8",
data: '{"parametro":"set_session","valor":"ca_imp","tabla":"' + ca_imp + '","campo":"","criterio":"","v1":""}',
dataType: "json",
success: function (devolucion) {
if (devolucion.d) {
$.ajax({
type: "POST",
url: "Respuestaajax.aspx/Respuestaaj",
contentType: "application/json; charset=utf-8",
data: '{"parametro":"set_session","valor":"cpo_imp","tabla":"' + cpo_imp + '","campo":"","criterio":"","v1":""}',
dataType: "json",
success: function (devolucion) {
if (devolucion.d) {
$.ajax({
type: "POST",
url: "Respuestaajax.aspx/Respuestaaj",
contentType: "application/json; charset=utf-8",
data: '{"parametro":"set_session","valor":"cpd_imp","tabla":"' + cpd_imp + '","campo":"","criterio":"","v1":""}',
dataType: "json",
success: function (devolucion) {
if (devolucion.d) {
}
},
error: function (req, status, error) {
alert("No hubo respuesta desde el servidor. Prueba otra vez.");
}
});
}
},
error: function (req, status, error) {
alert("No hubo respuesta desde el servidor. Prueba otra vez.");
}
});
}
},
error: function (req, status, error) {
alert("No hubo respuesta desde el servidor. Prueba otra vez.");
}
});
Cheers
The problem is something that still keeps happening to me with the handling of Ajax requests. And it is that what is outside the specific code of the Ajax request will be executed normally synchronously. In the question that I have formulated the two nested requests is not that they were not executed, but that the interference of the code following the requests was making me believe that the second and third requests were never executed. But once the rest of the code is finished, I have been able to print the returned values and the requests are actually made. I now have four requests, including the one that was outside of the previous nesting as the third nested request. As it is not done until the third is done, now everything that had to be done in that request happens satisfactorily and with the values of the server variables correctly updated previously by the previous requests. I put the code as it has been working. For that reason before I did not receive any error. Requests were made. There was also another factor that was confusing me. The synchronous code operation takes a long time to complete, and that initially led me to think that nested requests had disappeared. In the end all fixed. There was also another factor that was confusing me. The synchronous code operation takes a long time to complete, and that initially led me to think that nested requests had disappeared. In the end all fixed. There was also another factor that was confusing me. The synchronous code operation takes a long time to complete, and that initially led me to think that nested requests had disappeared. In the end all fixed.