[英]PHP $_GET data submitted via AngularJS
我一直在尋找相當多的東西,只能找到$ http.post()的例子。 我的問題是:
我通過AngularJS使用$ http.get提交數據但是當我輸出發送到我的PHP文件的數據時,它會持續出現NULL。 每當我使用$ http.post()時,事情都會相應地起作用。 我究竟做錯了什么。
PS - Noob到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
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();
采取瘋狂的猜測,但假設它與“php://輸入”有關,但我不知道實際在做什么 - 只是從另一個Stack帖子復制/粘貼。
謝謝
對於get請求,您將使用超級全局$_GET
來檢索發送的數據
echo json_encode($_GET); die();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.