JQuery的 - 嵌套的AJAX [英] JQuery - Nested AJAX
本文介绍了JQuery的 - 嵌套的AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图执行一个嵌套的AJAX调用使用下面的code。嵌套调用似乎并没有工作。难道我做错什么?
$。阿贾克斯({
键入:GET,
网址:/公/ customcontroller / DoSomething的,
缓存:假的,
数据类型:HTML,
成功:函数(html_input)
{
$阿贾克斯({
键入:GET,
网址:/公/ customcontroller / getjobstatus
缓存:假的,
数据类型:HTML,
成功:函数(html_input){
警报(html_input);
}
});
}
});
解决方案
您可以具有螺纹型的问题,因为外面的调用是异步的,可能会超出范围的成功处理程序之前可以发挥作用。尝试破成功召唤出到一个单独的功能。
I am trying to perform a nested AJAX call using the following code. The nested call doesn't seem to work. Am I doing anything wrong?
$.ajax({
type: 'GET',
url: "/public/customcontroller/dosomething",
cache: false,
dataType: "html",
success: function(html_input)
{
$.ajax({
type: 'GET',
url: "/public/customcontroller/getjobstatus",
cache: false,
dataType: "html",
success: function(html_input){
alert(html_input);
}
});
}
});
解决方案
You could be having thread-type issues, given that the outside call is asynchronous and may go out of scope before the success handler can come into play. Try breaking the success call out into a separate function.
这篇关于JQuery的 - 嵌套的AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文