使用预定义功能时回拨

时间:2017-06-20 19:41:49

标签: javascript jquery

我宣布了一项新功能。然后我稍后调用该函数。如果我调用的函数已完成,我该如何运行代码。 这是我的代码

var callLogin = function() {
    $(document).ready(function() {
        if(document.getElementById("userLoggedIn") === null) {
            $(".cover").fadeIn(200);
            $(".sixPinInputContainer").fadeIn(200);
            $("#pageBody").css("overflow", "hidden");
            $('.sixPinInput').first().focus();
        };
    })
};

然后这就是我所说的。问题是它在调用我的pin容器之前运行.load,所以即使pin不正确也会运行代码。

if (startBtn) {
        callLogin() 
        $("#" + rowID).load("eventHandlersPHP/updateStart.php", {
        roomID: id }, function(data, status) {
            $("#notStartedCount").load("eventHandlersPHP/jobsNotStartedCount.php"); 
            })
    };

1 个答案:

答案 0 :(得分:1)

记录得非常好here。你可以创建一些触发一个函数的动作,然后它可以调用另一个函数。另外,this will probably be a more helpful place for what it is you're trying to do

-Gonzo