我已經仔細考慮了這些日子,仍然無法弄清楚我做錯了什麼,所以任何想法或甚至在黑暗中的鏡頭都被讚賞。我試圖使用使用AngularJS $ http get方法顯示從休息服務對用戶的響應,但是當我將數據對象打印到控制檯時,我始終收到數字200(我相當肯定它給了我是狀態碼)。我每次都獲得成功,發送請求後,Chrome調試工具會向我顯示所有正確數據的響應。我似乎無法讓它出現在顯示的變量中。讓我知道,如果你想到任何東西!謝謝!
我的javascript:
$scope.resendDestinations = [];
$scope.resendDestGet = function() {
var omtTypeCodeString = '';
for(var i = 0; i < $scope.mySelections.length; i++){
if(omtTypeCodeString == ''){
omtTypeCodeString = $scope.mySelections[i].orderHeader.omtOrderTypeCode;
}
else{
omtTypeCodeString = omtTypeCodeString + ',' + $scope.mySelections[i].orderHeader.omtOrderTypeCode;
}
}
$http({
method: 'GET',
url: restService.pom + //service url,
respondType: 'json',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Credentials': true
},
params: {
orderTypeCode: omtTypeCodeString,
transactionCode: 3
}
}).success(function (status, data, response, header) {
console.log("Success!");
//TODO see if this is being used... has to be
status = parseInt(status);
$scope.resendDestinations = data.multipleOrders;
if (status == 200 && $scope.resendDestinations.length == 0) {
$scope.bigAlert.title = 'Error',
$scope.bigAlert.header = 'Search Error';
$scope.bigAlert.content = 'Current search parameters do not match any results.';
$scope.showBigAlert();
}
else{
$scope.resendDestinations = data;
console.log("Data DestinationList here: ");
console.log($scope.resendDestinations);
console.log(data.multipleOrders);
console.log(data);
}
$scope.isSearching = false;
}).error(function (response, data, status, header) {
//Do error things
});
return $scope.resendDestinations;
};
,服務響應:
[{"destCode":3,"destDescr":"Repository","attributes":null},{"destCode":4,"destDescr":"Pipeline","attributes":null},{"destCode":1,"destDescr":"Processor","attributes":null},{"destCode":2,"destDescr":"DEW","attributes":null}, {"destCode":7,"destDescr":"Management System","attributes":null}, {"destCode":8,"destDescr":"Source","attributes":null}]
更改函數標頭上狀態和數據的順序。 – Beterraba