mysql - Ionic App Breaks With PHP Scripts -
i followed this lynda tutorial working ionic app, , followed this lynda tutorial set mysql backend php scripts (i highly recommend both tutorials, way!). trying ionic app connected mysql database.
the ionic app grabs data js/data.json
, json data
in app.js
:
.controller('listcontroller', ['$scope', '$http', '$state', function($scope, $http, $state) { $http.get('js/data.json').success(function(data) { $scope.artists = data.artists; }); }]);
i wrote php script displays exact same thing data.json
. thought first step towards bridging gap between 2 tutorials.
in load_data.php
:
$response = ""; //omitting code fill $response //the same info data.json $json = json_encode($response); printf("%s", $json);
i have compared outputs of data.json
, load_data.php
, indeed identical. have used jsonlint make sure valid json. however, replacing js/data.json
js/load_data.php
makes data disappear no console or server errors.
also, when try go directly js/load_data.php
url, redirected index.html
, , browser downloads file instead of running it. have no idea why happens, because have no code in file other encoding , printing json data.
how can fix code ionic app can access mysql database?
can check this:
data = json.parse(data); $scope.artists = data.artists;
it parsing data
before using json object.
Comments
Post a Comment