<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="lib/jquery.js"></script>
</head>
<body>
    <div id="demo">this is show demo</div>
    <script>
        var wait = function () {
            var defer = $.Deferred();
            var tasks = function () {
                alert('Lazy Function!');
                defer.resolve();
            }
            setTimeout(tasks, 2000);
            return defer.promise();
        };

        $.when(wait()).done(function () {console.log('success!')}).fail(function () {console.log('fail')}) 

    </script>
</body>
</html>

 

相关文章:

  • 2021-09-08
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-06-17
  • 2021-11-12
  • 2021-08-04
猜你喜欢
  • 2021-08-01
  • 2021-11-08
  • 2022-12-23
  • 2022-01-19
  • 2021-10-22
  • 2021-07-15
  • 2022-02-20
相关资源
相似解决方案