Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从编码JSON的PHP页面获取数据?_Php_Angularjs_Json_Ionic Framework - Fatal编程技术网

如何从编码JSON的PHP页面获取数据?

如何从编码JSON的PHP页面获取数据?,php,angularjs,json,ionic-framework,Php,Angularjs,Json,Ionic Framework,请帮帮我,伙计们。我已经思考了几个小时如何解决这个问题,但我仍然不知道如何解决。> 为了访问Js文件中的数据,必须使用ajax。 需要数据时调用ajax 有关更多详细信息,请参阅下面的链接 试试: $http.get('resources/json/jsonfile.php',{ responseType : 'json' }) 您能将您的Ajax响应记录到console.log中吗$http.get('resources/json/jsonfile.php')。然后(函数(数据){conso

请帮帮我,伙计们。我已经思考了几个小时如何解决这个问题,但我仍然不知道如何解决。> 为了访问Js文件中的数据,必须使用ajax。 需要数据时调用ajax

有关更多详细信息,请参阅下面的链接

试试:

$http.get('resources/json/jsonfile.php',{ responseType : 'json' })

您能将您的Ajax响应记录到console.log中吗<代码>$http.get('resources/json/jsonfile.php')。然后(函数(数据){console.log(数据);})
[{"account_id":"89","username":"2012100014","password":"25d55ad283aa400af464c76d713c07ad"},{"account_id":"90","username":"2012102400","password":"25d55ad283aa400af464c76d713c07ad"},{"account_id":"91","username":"2012101087","password":"25d55ad283aa400af464c76d713c07ad"},{"account_id":"92","username":"2011102090","password":"25d55ad283aa400af464c76d713c07ad"}]
app.service("myService", function($http,$q)
{
  var deferred = $q.defer();
  $http.get('resources/json/jsonfile.php').then(function(data)
  {
    deferred.resolve(data);
  });
  this.getAccounts = function()
  {
    return deferred.promise;
  }

})
.controller("myCtrl",function($scope,myService)
{
  var promise = myService.getAccounts();
  promise.then(function (data)
  {
    $scope.allAccounts = data;
    var accounts = data;
    console.log($scope.allAccounts);
  });

})
Object {data: "<?php
↵    //open connection to mysql db
↵    $con…db connection
↵    mysqli_close($connection);
↵?>", status: 200, config: Object, statusText: "OK"}
$http.get('resources/json/jsonfile.php',{ responseType : 'json' })