• async/await


    // 拿code
    let getCode = () => {
        let p = new Promise((resolve, reject) => {
            $.ajax({
                url: './json/code.json',
                success(res){
                    resolve(res.code);
                }
            })
        })
        return p;
    }
    
    // 拿数据
    let getMsg = (code) => {
        let p = new Promise((resolve, reject) => {
            $.ajax({
                url: './json/person.json',
                data: code,
                success(res){
                    resolve(res)
                }
            })
        })
        return p
    }
    
    let con = async () => {
        try{
            let code = await getCode()
            let list = await getMsg(code)
            console.dir(list.list)
        }catch(e){
            console.log('error', e)
        }
    }
    con()

    .

  • 相关阅读:
    PHP+AJAX 验证码验证用户登录
    2014-05-09 总结
    2014-05-08 总结(补充)
    2014-05-08 总结
    2014-05-07 总结
    14-6-2
    php
    5-23
    PHP
    5-22
  • 原文地址:https://www.cnblogs.com/xulinjun/p/11889269.html
Copyright © 2020-2023  润新知