[英]I am working on php using angularjs in the below programme i didnt get any responce from ajax call.i didnt get whats the wrong in below code
在下面的代碼中,我想打印出mock.json文件的值。 我在angularjs中使用php。在這段代碼中,我給了ajax調用的ajax調用位結果是什么(響應變量為空)。我是angularjs的新手,請告訴我這是什么錯誤。
<!doctype html>
<html lang="en" ng-app="angularTable">
<script src="lib/angular/angular.js"></script>
<script src="lib/dirPagination.js"></script>
<script >
var app=angular.module('angularTable',[]);
app.controller('listdata',function($scope,$http) {
$scope.users=[];
$http.get("mockJson/mock.json").success(function(responce){
$scope.users = response;
})
.error(function(data) {
console.error('Repos error', data);
})
});
</script>
<body>
<div ng-controller="listdata">
<table>
<tr>
<th>Id</th>
<th>Name</th>
</tr>
<tr ng-repeat="users in users">
<td>{{users.id }}</td>
<td>{{users.first_name }}</td>
</tr>
</table>
</div>
</body>
</html>
///Json File(mock.json)
[{"id":1,"first_name":"Heather","last_name":"Bell","hobby":"Eating"},
{"id":2,"first_name":"Andrea","last_name":"Dean","hobby":"Gaming"},
{"id":3,"first_name":"Peter","last_name":"Barnes","hobby":"Reading Books"},
{"id":4,"first_name":"Harry","last_name":"Bell","hobby":"Youtubing"},
{"id":5,"first_name":"Deborah","last_name":"Burns","hobby":"Fishing"},
{"id":6,"first_name":"Larry","last_name":"Kim","hobby":"Skipping"},
{"id":7,"first_name":"Jason","last_name":"Wallace","hobby":"Football"},
{"id":8,"first_name":"Carol","last_name":"Williams","hobby":"Baseball"},
{"id":9,"first_name":"Samuel","last_name":"Olson","hobby":"Programming"},
{"id":10,"first_name":"Donna","last_name":"Evans","hobby":"Playing DOTA"},
{"id":11,"first_name":"Lois","last_name":"Butler","hobby":"Gaming"},
{"id":12,"first_name":"Daniel","last_name":"Hill","hobby":"surfing"},
{"id":13,"first_name":"Matthew","last_name":"Torres","hobby":"cycling"},
{"id":14,"first_name":"Jerry","last_name":"Hernandez","hobby":"Music"},
{"id":15,"first_name":"Christopher","last_name":"Carpenter","hobby":"Football"},
{"id":16,"first_name":"Harold","last_name":"West","hobby":"Gaming"},
{"id":17,"first_name":"Carol","last_name":"Hicks","hobby":"Youtubing"},
{"id":18,"first_name":"Bonnie","last_name":"Davis","hobby":"Partying"},
{"id":19,"first_name":"Nancy","last_name":"Banks","hobby":"Photography"},
{"id":20,"first_name":"Walter","last_name":"Freeman","hobby":"Tweeting"},
{"id":21,"first_name":"Louis","last_name":"Gonzales","hobby":"Bloging"},
{"id":22,"first_name":"Jean","last_name":"Watkins","hobby":"Bloging"},
{"id":23,"first_name":"Albert","last_name":"Harris","hobby":"Music"},
{"id":24,"first_name":"Billy","last_name":"Owens","hobby":"Camping"},
{"id":25,"first_name":"Russell","last_name":"Patterson","hobby":"Singing"}]
在您的代碼中:
$http.get("mockJson/mock.json").success(function(responce){
$scope.users = response;
})
的參數的函數是性反應 ,而被分配給變量$scope.users
是響應 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.