在实际业务中经常需要等待几个请求完成后再进行下一步操作。但angularjs中$http不支持同步的请求。
解决方法一:
解决方法二:
then中的方法会按顺序执行。
getJson(\'json1.txt\').then(function(){
return getJson(\'json2.txt\');
}).then(function(){
return getJson(\'json1.txt\');
}).then(function(){
return getJson(\'json2.txt\');
}).then(function(d){
console.log(\'end\');
});
});
本文地址:https://www.stayed.cn/item/5697
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我