我正在尝试对我的服务器上的php文件执行http请求。我现在使用的代码如下:有自定义数据的角度http请求
App.controller('GetSales', ['$scope', '$http', function ($scope, $http) {
$http({
method: 'POST',
url: '/app/controller/apis/_sales.php?period_start=2015-07-01&period_end=2015-07-31&join=leads&status=0&category=0user=1'
})
.success(function (data) {
$scope.sales = data;
});
}]);
还没有更好的方法来做到这一点? 当我将这些var作为数据添加它不会发布到我的页面?
data: {
period_start: '2015-07-01',
period_end: '2015-07-31',
join: 'leads',
status: '',
category: '',
user: '1'
};
在PHP时得到这样的数据,其也消毒出于安全原因:
$user = filter_var($_REQUEST['user'], FILTER_SANITIZE_NUMBER_INT);
$period_start = $_REQUEST['period_start'].' 00:00:00';
我的回答已被更新,这是用来访问AngularJS不正确的API。查看我的演示并链接到$ http的Angular Docs。这是使用jQuery风格,但与Angular,不会工作。 –
你的问题不是客户端在这一点上,我延伸我的答案低于 –
那么我坐在这已经像“永远”,我不知道什么是失踪? –