简体   繁体   English

我在下面的程序中使用angularjs在php上工作,我没有从ajax call得到任何响应。我没有在下面的代码中得到什么错了

[英]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

In below code i want to print the values of mock.json file. 在下面的代码中,我想打印出mock.json文件的值。 I am using the php with angularjs.in this code i gave the ajax call bit result from ajax call is nothing (in responce variable is blank).i am new with angularjs please tell me what is wrong. 我在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"}]

In your code: 在您的代码中:

$http.get("mockJson/mock.json").success(function(responce){

    $scope.users = response; 
})

the argument to the function is responce while the variable that is assigned to $scope.users is response . 的参数的函数是性反应 ,而被分配给变量$scope.users响应

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何得到json响应从PHP格式下? - how do i get json responce from php below format? 卷曲不起作用,我没有得到任何结果 - curl doesnt work and i didnt get any result 我已经尝试使用ajax调用我的PHP函数,但我不知道它的代码错误是什么不起作用 - I have tried using ajax to call into my php function but i dont know whats wrong with the code its not working 使用window.open时出现弹出窗口,我不想弹出窗口,必须直接打开链接 - i am getting the popup when using the window.open, i didnt want to get the popup, link has to be open directly 如何使用ajax在数据库中插入复选框值...我正在尝试以下代码不起作用 - How to insert the checkbox value in database using ajax… i am trying below code not not working 我没有得到wampserver所需的结果 - I didnt get the desired result with wampserver in the <? syntax.Why? 需要帮助php数组,我不知道 - Need help php array that i didnt know 我无法在 cloudfront 中获得签名的 url,出现致命错误,我正在尝试的代码如下 - I am not able to get signed url in cloudfront, getting fatal error, code I am trying is below 我如何从以下条件获取索引数组php - how can i get index array php from condition below 我正在使用php,json服务,而我在执行以下代码时却得到了空白页,数据库中未更新任何数据……如果出错,请更正我 - Am using php, json services while i execute below code i am getting a blank page, no data updated in database…correct me if wrong
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM