$resource returns undefined


#1

Below is a code fragment with problem. When it runs without wifi, it works well, but in some wifi, data returned is undefined. However, when access the resource in a web browser, the returned value is correct. Does anyone run into this problem? Any suggestion is appreciated.

var refreshIndex = function () {
var datasource = $resource(baseUrl + ‘K/MarketBrief’);
datasource.get(function (data) {
$scope.mainIndex = data.MainIndexs;
$scope.stats = data.MarketStats;
for (var i = 0; i < $scope.mainIndex.length; i++) {
$scope.ia[i].C = $scope.mainIndex[i].C;
$scope.ia[i].BR = $scope.mainIndex[i].BR;
}
});
}