JQuery的 - 嵌套的AJAX嵌套、JQuery、AJAX

由网友(触碰脆弱)分享简介:我试图执行一个嵌套的AJAX调用使用下面的code。嵌套调用似乎并没有工作。难道我做错什么?$。阿贾克斯({键入:GET,网址:/公/ customcontroller / DoSomething的,缓存:假的,数据类型:HTML,成功:函数(html_input){$阿贾克斯({键入:GET,网址:/公/...

我试图执行一个嵌套的AJAX调用使用下面的code。嵌套调用似乎并没有工作。难道我做错什么?

  $。阿贾克斯({
键入:GET,
网址:/公/ customcontroller / DoSomething的,
缓存:假的,
数据类型:HTML,
成功:函数(html_input)
{
    $阿贾克斯({
        键入:GET,
        网址:/公/ customcontroller / getjobstatus
        缓存:假的,
        数据类型:HTML,
        成功:函数(html_input){
        警报(html_input);
        }
    });
}
});
 

解决方案

您可以具有螺纹型的问题,因为外面的调用是异步的,可能会超出范围的成功处理程序之前可以发挥作用。尝试破成功召唤出到一个单独的功能。

3 jQuery AJAX

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.

阅读全文

相关推荐

最新文章