[英]PHP $_GET data submitted via AngularJS
I've been searching around quite a bit and can only find $http.post() examples. 我一直在寻找相当多的东西,只能找到$ http.post()的例子。 My problem is: 我的问题是:
I submit data via AngularJS with $http.get however when I out the data sent to my PHP file it continuously comes up NULL. 我通过AngularJS使用$ http.get提交数据但是当我输出发送到我的PHP文件的数据时,它会持续出现NULL。 Whenever I use $http.post() things work accordingly. 每当我使用$ http.post()时,事情都会相应地起作用。 What am I doing wrong. 我究竟做错了什么。
PS - Noob to Angular PS - Noob到Angular
ANGULAR ANGULAR
(function ()
{
var app = angular.module('app', ['ngRoute']);
app.config(function($routeProvider){
$routeProvider
.when('/players', {
templateUrl: 'partials/players.html',
controller: 'PlayersController'
})
.otherwise({
redirectTo: 'index.html'
});
});
app.controller('PlayersController', ['$scope', '$http', function ($scope, $http)
{
$http
.get('executer.php', {
params: {
league: "NFL",
team: "Ravens"
}
})
.success(function(response)
{
console.log(response);
})
.error(function()
{
console.log("error");
});
}
]);
})
();
PHP PHP
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/php/Class/Database.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/php/Class/Search.php');
$data = json_decode(file_get_contents("php://input"));
echo json_encode($data); die();
Taking a wild guess, but assuming it has to do with "php://input", however I have no clue what that is actually doing - merely copy/pasted from another Stack post. 采取疯狂的猜测,但假设它与“php://输入”有关,但我不知道实际在做什么 - 只是从另一个Stack帖子复制/粘贴。
Thanks 谢谢
对于get请求,您将使用超级全局$_GET
来检索发送的数据
echo json_encode($_GET); die();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.