第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

關(guān)于promise ajax 使用then順序執(zhí)行的問題

關(guān)于promise ajax 使用then順序執(zhí)行的問題

慕勒3428872 2019-03-07 13:15:26
需要按順序執(zhí)行 ajax請(qǐng)求,之前請(qǐng)求到的數(shù)據(jù)需要傳給下一個(gè)函數(shù),一共需要走五步,使用resolve(xxx)來傳到下一個(gè) promise里,但是到了第3步就開始報(bào)錯(cuò)了,求大神指導(dǎo)這個(gè)是在node環(huán)境下測(cè)試的var superagent = require('superagent')var p1 = function (path) {    return new Promise(function (resolve, reject) {        superagent.get(path).end(function (err, res) {            if (err) {                console.log('err1')            } else {                if (res.status == 200) {                    console.log('step1')                    resolve(path);                }            }        })    });}var p2 = function (path) {    return new Promise(function (resolve, reject) {        superagent.get(path).end(function (err, res) {            if (err) {                console.log('err2')            } else {                if (res.status == 200) {                    console.log('step2')                    resolve(path)                }            }        })    });}var p3 = function (path) {    return new Promise(function (resolve, reject) {        superagent.get(path).end(function (err, res) {                        if (err) {                console.log('err3')            } else {                if (res.status == 200) {                    console.log('step3')                    resolve()                }            }        })    });}var p4 = function (path) {    return new Promise(function (resolve, reject) {        superagent.get(path).end(function (err, res) {                        if (err) {                console.log('err4')            } else {                if (res.status == 200) {                    console.log('step4')                    resolve()                }            }        })    });}p1("http://www.baidu.com").then(function (val) {p2(val)}).then(function (val) {p3(val)}).then(function (val) {p4(val)})打印結(jié)果:step1報(bào)錯(cuò)報(bào)錯(cuò)step2發(fā)現(xiàn)第二步開始值就沒有傳到第三步里,并且也沒有按 step1---》step4這個(gè)順序執(zhí)行求指導(dǎo)
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 1446 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)