标签:col type post syn string promise The 解决 span
function a(){ return new Promise(function(res,rej){ $.ajax({ url:"a", type: "GET", async:true, dataType:"json", success:function(data){ console.log(data,"a"); res(data); } }) }); } function b(data){ console.log(data,"data"); return new Promise(function(res,rej){ $.ajax({ url:"b", type: "POST", async:true, data:JSON.stringify(data), dataType:"json", success:function(data){ console.log(data,"b"); res(); } }) }); } $("#btn").click(function(){ a().then(function (data){ b(data); }).then(function(){ }) })
b的请求结果依赖于a的数据
标签:col type post syn string promise The 解决 span
原文地址:https://www.cnblogs.com/celine-huang/p/11130942.html