Thứ Hai, 13 tháng 7, 2015

One way to excute a function javascript after another function finish

If you have two function javascript (or more) named Fn1 and Fn2, and you want to excute Fn2 when Fn1 finish. This is the one way to do it.

function F1(){
      //do somthing you want
      return true;
}

function F2(){
     //do something you want
}

And then excute in your script. Example:

<script>
      $(document).ready(function(){
            if(Fn1() == true){ //this line guarantee Fn1 function finish and then Fn2 function execute
                  Fn2();
            }
      });
</script>

Không có nhận xét nào:

Đăng nhận xét