Global variable has no value

problem description

after the assignment operation, the contents of the global variable are empty.

the environmental background of the problems and what methods you have tried

Google browser. Using var to define global variables also has no effect.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
$scope.collection= {};

$scope.list={};
$scope.controlMap={};
$scope.initzhanquzhang=function(){
    $http({
        method:"POST",
        url:"Report/ReportSearch",
        data:{ReportSearchCode:"getSalesKqDataBuManager3",salesDateStr:$scope.searchData.salesDateStr,kindCode:$scope.kindCode}
    })
    .success(function(result, status, headers, config){ 
        angular.forEach(result,function(data,index,array){
            //collectionkindCodeAndBuName
            var buName=data.buName;
            var kindCode = data.kindCode;
            var kindCodeAndBuName=kindCode+"_"+buName;
            $scope.collection[kindCodeAndBuName]=[];
            $scope.list[kindCodeAndBuName]=[];
            $scope.controlMap[kindCodeAndBuName]=null;
        });
        $http({
            method:"POST",
            url:"Report/ReportSearch",
            data:{ReportSearchCode:"getSalesKqDataDetailBuManager3",salesDateStr:$scope.searchData.salesDateStr,kindCode:$scope.kindCode}
        })
        .success(function(result, status, headers, config){ 
            angular.forEach(result,function(data,index,array){ 
                //
                var buName=data.buName;
                var kindCode = data.kindCode;
                var kindCodeAndBuName=kindCode+"_"+buName;
                if($scope.collection.hasOwnProperty(kindCodeAndBuName) ){
                    if(data.longitude && data.latitude ){
                        $scope.collection[kindCodeAndBuName].push(new BMap.Point(data.longitude,data.latitude));
                    }
                    $scope.list[kindCodeAndBuName].push(data);
                }
            });
            alrt(JSON.stringify($scope.list));
            /*$http({
                method:"POST",
                url:"Report/ReportSearch",
                data:{ReportSearchCode:"getSalesKqDataBuManager3",salesDateStr:$scope.searchData.salesDateStr,kindCode:$scope.kindCode}
            })
            .success(function(result, status, headers, config){ 
                angular.forEach(result,function(data,index,array){
                    var buName=data.buName;
                    var kindCode = data.kindCode;
                    var kindCodeAndBuName=kindCode+"_"+buName;
                    
                    var options = {
                            size: BMAP_POINT_SIZE_SMALL,
                            shape: BMAP_POINT_SHAPE_STAR,
                            color: "yellow",
                            scale: 0.5
                        }
                    if($scope.controlMap.hasOwnProperty(kindCodeAndBuName) ){
                        $scope.controlMap[kindCodeAndBuName] = new BMap.PointCollection($scope.collection[kindCodeAndBuName], options);
                    }
                });
            });*/
        });
    });
};
$scope.initzhanquzhang();
alert(JSON.stringify($scope.collection));

what result do you expect? What is the error message actually seen?

expect to see a value in the variable. What time sees is {}.

Apr.11,2021

The

http request is an asynchronous operation and the code in the callback is not executed until the success callback.

however, your value is taken immediately after the request is initiated.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36d43-2c03f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36d43-2c03f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?