Jquery continue another ajax function after the first ajax function call is fully complete

后端 未结 6 1296
陌清茗
陌清茗 2021-01-04 00:10

I have 2 ajax call in 2 difference functions. I want to use .click to call these 2 functions . The func1 is inserting data in to database, then func2 is to retrieve the data

6条回答
  •  无人及你
    2021-01-04 00:59

    Move func2 inside func1->ajax->succes callback

    $("#updateLocation").click(function(e) {
        e.preventdefault;
        func1();
        //func2();
    });
    return false;
    });
    
    function func1() {
        $.ajax({
            url: '',
            success: function() { /* other stuff */
                func2();
            }
        });
    });
    
    function func2() {
        $.ajax({
            url: '',
        });
    });
    

提交回复
热议问题