Php Angularjs Get方法
在控制台和数据中获取以下错误不是从mysql获取的。有人能就以下错误提出建议吗: 使用angularjs、php、mysql和ECSS 错误:$http.get(…)。成功不是一个函数 以下是我的控制器的代码:Php Angularjs Get方法,php,angularjs,Php,Angularjs,在控制台和数据中获取以下错误不是从mysql获取的。有人能就以下错误提出建议吗: 使用angularjs、php、mysql和ECSS 错误:$http.get(…)。成功不是一个函数 以下是我的控制器的代码: .controller('dashBoardCtrl', ['$scope', '$http', function ($scope, $http) { $http.get("dbconnection/db_read.php") .success(functi
.controller('dashBoardCtrl', ['$scope', '$http', function ($scope, $http)
{
$http.get("dbconnection/db_read.php")
.success(function(data)
{
$scope.data = data;
console.log(data);
})
.error(function()
{
$scope.data = "error in fetching data";
});
}]
);
你能试试吗
$http.get().then(function(result){console.log(result)});
我认为
.success
不受欢迎。您很可能使用AngularJS 1.6+
.success(fnsucture)
和.error(fnError)
不再存在
使用。然后(fnSuccess,fnError)
所以
现在是
$http.get(...).then(function success() {}, function error() {});
让我们看看:
因此,您将成功和错误回调传递给
then()
notsuccess()
.controller('dashBoardCtrl',['$scope','$http',function($scope,$http){$http.get(“dbconnection/db_read.php”)。成功(function(data){$scope.data=data;console.log(data);}).error(function(){$scope.data=“获取数据时出错”;});}]);如果您需要添加到您的问题中,只需使用“编辑”按钮而不是注释。然后只需说您添加了编辑,可能会将“编辑”设置为粗体。并在您要添加的内容周围添加一些上下文。1.5中不推荐该内容。1.6中完全删除该内容感谢所有人提供您的建议。问题已解决
$http.get(...).then(function success() {}, function error() {});
// Simple GET request example:
$http({
method: 'GET',
url: '/someUrl'
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});