$http({ 'url':'/jtkj/yjmc', 'method':'POST', }) .success(function(res) { $scope.yjdh = res; console.log(res); var navUrl = ['/genSit','/news','/set','/manage','/cooperate','/admNet','/eplNet','/stuMan']; //傳值,循環遍歷出數據 $scope.xlcd = []; for(var i=0;i<res.length;i++){ $scope.yjid = res[i].yjid; console.log(res[i].yjid); ejnameGet($scope.yjid); $http({ url:'/jtkj/ejmc', method:'POST', data:{yjid:$scope.yjid} }).success(function(xlcd1){ //$scope.xlcd = xlcd1; console.log(xlcd1); xlcd.push(xlcd1); }) } //console.log($scope.xlcd); $scope.xlcd = xlcd; console.log($scope.xlcd);
for循環執行多個異步請求,但是請求到的數據順序打亂了?
隔江千里
2018-11-28 22:18:34