Updated, this is code that was just tested with php and Apache - and it works. I also changed your server.php file like below. The file was created based on AngularJS Hub's Server Calls sample. The same source was used to create mainController.js' $http.post(...) method call so that it successfully posts data to the server.
Screenshot (after submit)
server.php
<?php
if ($_SERVER["REQUEST_METHOD"] === "POST")
{
$result = "POST request received!";
if (isset($_GET["name"]))
{
$result .= "
name = " . $_GET["name"];
}
if (isset($_GET["email"]))
{
$result .= "
email = " . $_GET["email"];
}
if (isset($HTTP_RAW_POST_DATA))
{
$result .= "
POST DATA: " . $HTTP_RAW_POST_DATA;
}
echo $result;
}
?>
personForm.html
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body ng-app="mainModule">
<div ng-controller="mainController">
<form name="personForm1" validate ng-submit="submit()">
<label for="name">First name:</label>
<input id="name" type="text" name="name" ng-model="person.name" required />
<br />
{{person.name}}
<br />
<label for="email">email:</label>
<input id="email" type="text" name="email" ng-model="person.email" required />
<br />
<br />
<button type="submit">Submit</button>
</form>
<br />
<div>
{{serverResponse}}
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
<script src="mainController.js"></script>
<!--<script type="text/javascript" src="script/parsley.js"></script>
<script src="script.js"></script>-->
</body>
</html>
mainController.js
angular.module("mainModule", [])
.controller("mainController", function ($scope, $http)
{
$scope.person = {};
$scope.serverResponse = "";
$scope.submit = function ()
{
console.log("form submit");
var params = {
name: $scope.person.name,
email: $scope.person.email
};
var config = {
params: params
};
$http.post("server.php", $scope.person, config)
.success(function (data, status, headers, config)
{
console.log("data " + data + ", status "+ status + ", headers "+ headers + ", config " + config);
$scope.serverResponse = data;
console.log($scope.serverResponse);
})
.error(function (data, status, headers, config)
{ console.log("error");
$scope.serverResponse = "SUBMIT ERROR";
});
};
});// JavaScript source code
Alternative way, with JSON handling:
server_json.php
<?php
if ($_SERVER["REQUEST_METHOD"] === "POST")
{
/* code source: http://stackoverflow.com/a/22852178/2048391 */
$data = array();
$json = file_get_contents('php://input'); // read JSON from raw POST data
if (!empty($json)) {
$data = json_decode($json, true); // decode
}
print_r($data);
}
?>
Screenshot (after submit)