-1
这里是我的问题,从MySQL获得的数据。所以PHP文件(链接到MySQL数据库)输出为:AngularJS通过PHP文件
[{"hum":"55.36","temp":"20.86","unixtime":"2015-10-29 17:39:42","coreid":"xxxxxx","moist":"0.02","volt":"4.30","soc":"114"},
{"hum":"55.33","temp":"20.84","unixtime":"2015-10-29 17:39:50","coreid":"xxxxxx","moist":"0.00","volt":"4.30","soc":"114"},
{"hum":"55.42","temp":"20.84","unixtime":"2015-10-29 17:39:58","coreid":"xxxxxx","moist":"0.02","volt":"4.30","soc":"114"}]
应用程序的代码是:
var dashb = angular.module('dashboard', []);
//avoid cross domain issue
dashb.config(['$httpProvider', function($httpProvider) {
$http.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}
]);
dashb.controller('dbCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get("http://www.domain.com/php_file_url.php")
.success(function(data) {
$scope.data = data;
$scope.hum = data.hum;
})
.error(function() {
$scope.data = "error in fetching data";
});
}]);
但是当我运行它,它不工作。我没有收到任何数据。我做错了什么?谢谢
检查浏览器开发工具网络线索的实际要求。你对“不起作用”的解释不会告诉我们任何东西 – charlietfl
在网络标签中我什么都看不到,字面意思:( –
这真的没有道理。没有一些调试信息没有任何人可以帮你 – charlietfl