I searched quite a lot and can only find http.post () examples. My problem:
I send data via AngularJS with $ http.get, however, when I send data sent to my PHP file, it constantly appears NULL. Whenever I use $ http.post (), everything works accordingly. What am I doing wrong.
PS - Noob to 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();
Accepting a wild assumption, but assuming it's related to "php: // input", however, I don't know what this actually does - just copy / paste from another Stack column.
thanks
source
share