Promise

作者: 哈哈我爱你 | 来源:发表于2018-12-13 10:44 被阅读0次
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title></title>
            <style>
            </style>
        </head>
        <body>
        </body>
        <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
        <script>
            var promise1 = new Promise((resolve,reject)=>{
                $.ajax({
                 type: "POST",
                 url: "XXX",
                 data: {},
                 dataType: "json",
                 success: reject,
                 error:reject
                });
            }).then(res=>{
                // console.log(res,'listBbsUserInfo')
                // throw new Error('listBbsUserInfo')
                return res
            })
            var promise2 = new Promise((resolve,reject)=>{
                $.ajax({
                type: "POST",
                url: "XXX",
                data: {},
                dataType: "json",
                success: resolve,
                error:reject
                });
            }).then(res=>{
                // console.log(res,'listUserBlockReason')
                return res
            })
            Promise.all([promise1,promise2]).then(res=>{
                console.log(res,'all')
            }).catch(err=>{
                console.log(err,'err')
            })
        </script>
    </html>
    

    相关文章

      网友评论

          本文标题:Promise

          本文链接:https://www.haomeiwen.com/subject/swjvhqtx.html