angular.js - Problems with $http.post request data when using angular
为情所困
为情所困 2017-05-27 17:44:38
0
3
904

When using $http.post in angular to request data, I found that the data after each request is the updated data when viewed in the console Network, but in $http.post (data address, parameters). success(function(response){$scope.datas=response.data;
console.log(response.data.vote_options) //This is the printed data but it is different from the data viewed in the console (a certain parameter value) Inconsistent, why??}), please see the specific code below:

            var voteposturl="/Api/Share/GetVoteInfo";
            var votepostparameter="&nid="+nid+"&vote_id="+$scope.voteid;
            $http.post(voteposturl,votepostparameter).success(function(response){
                $scope.datas=response.data; //总体数据
                console.log(response.data.vote_options) //现打印其数据结构中具体的一个数组数据
                console.log(response.data.vote_options[0].is_voted) //现打印其数据结构中具体的一个数组数据里面具体一条数据中的参数值,该参数值与在控制台查看的接口那里的数据又是保持一致,不知道为什么会这样
            }) 

Please see the data comparison after the request:

  1. This is the printed data //console.log(response.data.vote_options)

  2. ##This is the real data of the network when viewing the requested interface on the console

Does anyone know what causes this? Is it because $http is cached? Or is it because of other reasons?

为情所困
为情所困

reply all(3)
phpcn_u1582

Change your browser and see if the problem is the same. Chrome has some bugs

伊谢尔伦

It is likely that its value has been modified in some places in your code.
Print response.data above $scope.datas = response.data;. Check if it is consistent with the console

某草草

Maybe you performed data operations in some places you didn’t pay attention to. Angular is not good at this. If you move it slightly, everything will change.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template