Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS+;PHP联系方式,邮政405(不允许)_Php_Angularjs_Nginx - Fatal编程技术网

AngularJS+;PHP联系方式,邮政405(不允许)

AngularJS+;PHP联系方式,邮政405(不允许),php,angularjs,nginx,Php,Angularjs,Nginx,每当我试图通过联系人表单发送消息时,控制台中就会出现POST 405(不允许) App.js $scope.submitData = function() { $http({ url: 'handle.php', method: 'POST', data: {"name": $scope.name,"email": $scope.email,"message": $scope.message}, headers: {'Content-Type': 'applicat

每当我试图通过联系人表单发送消息时,控制台中就会出现POST 405(不允许)

App.js

$scope.submitData = function() {
   $http({
   url: 'handle.php',
   method: 'POST',
   data: {"name": $scope.name,"email": $scope.email,"message": $scope.message},
   headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
   })
   .success(function() {
     window.alert("Success");
   })
   .error(function() {
     window.alert("Failure");
   })
}
Handle.php

$json = file_get_contents("php://input");
$data = json_decode($json, true);

$to = "myemail@gmail.com";
$name = $data['name'];
$email = $data['email'];
$message = $data['message'];

//to, subject, message, headers, parameters.
mail($to, $name, $email, $message);
?>
Contact.html

<form action="" method="post" ng-submit="submitData()" ng-controller="contactController">
<p>name:</p>
<input name="name" type="text" ng-model="name">
<p>email:</p>
<input name="email" type="text" ng-model="email">
<p>message:</p>
<textarea name="message" type="text" cols="40" rows="5" ng-model="message"></textarea>
<p><div id="html_element"></div><p>
<input type="submit" id="submit" value="Submit"/>
</form>

姓名:

电邮:

信息:

我正在raspberry pi上运行一个nginx web服务器

handle.php是否正确

我假设这个错误意味着服务器上没有配置什么?我需要配置什么


非常感谢您的帮助。

我认为您应该安装一个插件,以便向其他服务器调用ajax。尝试下载此文件,可能会有所帮助:

安装后,单击插件、添加和url: 然后再试一次