Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/88.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
Javascript 提交后phpmailer+;安格拉斯_Javascript_Angularjs_Email_Phpmailer - Fatal编程技术网

Javascript 提交后phpmailer+;安格拉斯

Javascript 提交后phpmailer+;安格拉斯,javascript,angularjs,email,phpmailer,Javascript,Angularjs,Email,Phpmailer,我有一个简单的3页html。索引、联系人和服务。我用ng视图调用模板视图html。一切都很好。我看到他们在导航栏上有按钮 在contact.html中,我想使用来自“”的phpmailer和教程 在我的控制器中,我将代码JS粘贴到新的控制器中,并在html文件中使用与教程相同的格式。在不同的测试之后,我到达控制器工作,但是当我脉冲输入提交时:没有发生任何事情,也没有发送任何东西 我在代码控制器中更改相对于exampledomain.net/js/contact-form.php的路径。将联系人表

我有一个简单的3页html。索引、联系人和服务。我用ng视图调用模板视图html。一切都很好。我看到他们在导航栏上有按钮

在contact.html中,我想使用来自“”的phpmailer和教程

在我的控制器中,我将代码JS粘贴到新的控制器中,并在html文件中使用与教程相同的格式。在不同的测试之后,我到达控制器工作,但是当我脉冲输入提交时:没有发生任何事情,也没有发送任何东西

我在代码控制器中更改相对于exampledomain.net/js/contact-form.php的路径。将联系人表单中的so更改为调用PHPMailerAutoload.php的路径

在contactform.html中,我在第一个div中输入了对控制器的调用)和相同的表单示例

在contact-form.php中,所有内容都与教程相同,只是我像以前一样更改了路径)

是否可能因为我使用ng视图,所以post表单不起作用?有人知道为什么contact-form.php似乎没有运行吗

我是一个非常初学者。谢谢 我拥有的唯一控制器的代码(用于路由和表单phpmailer):

//Creo模y su nbre+establecer函数路由
var-AppSol=angular.module('AppSol',['ngRoute']);
//配置路由
AppSol.config(函数($routeProvider){
$routeProvider
//印度链接页面导航
。当(“/”{
templateUrl:'templates/home.html',
控制器:“”
})
.否则({
重定向至:“/”
})
。当(“/Inicio”{
templateUrl:'templates/home.html',
控制器:'MainCtrl'
})  
.当(“/Contacto”{
templateUrl:'templates/contacto.html',
控制器:'ContactController'
})  
.当(“/Servicios”{
templateUrl:'templates/servicios.html',
控制器:'ServCtrl'
}); 
});
//Creo控制器与lo注入
AppSol.controller('MainCtrl',函数($scope){
//可能的功能
$scope.titulo=“我的头衔”;
});
//Creo控制器与lo注入
AppSol.controller('ServCtrl',函数($scope){
//可能的功能
$scope.message='';
$scope.titulo='第二个标题'
});
//Creo控制器与lo注入
AppSol.controller('ContactController',函数($scope,$http){
$scope.titulo='TEST1呼叫联系人控制器'
//$scope.result='Hidden'
$scope.resultMessage='Test2和结果控件-我看到了这个mensaje';
$scope.formData;//formData是一个包含名称、电子邮件、主题和消息的对象
$scope.submitButtonDisabled=false;
$scope.submitted=false;//用于仅在提交表单后显示表单错误
$scope.submit=函数(contactform){
$scope.submitted=true;
$scope.submitButtonDisabled=true;
如果(联系方式:$valid){
$http({
方法:“POST”,
网址:'http://exampledomain.net/test/js/contact-form.php',
数据:$.param($scope.formData),//jQuery中的param方法
标题:{'Content Type':'application/x-www-form-urlencoded'}//将标题设置为将信息作为表单数据传递(而不是请求负载)
}).成功(功能(数据){
控制台日志(数据);
if(data.success){//success来自返回的json对象
$scope.submitButtonDisabled=true;
$scope.resultMessage=data.message;
$scope.result='bg-success';
}否则{
$scope.submitButtonDisabled=false;
$scope.resultMessage=data.message;
$scope.result='bg-danger';
}
});
}否则{
$scope.submitButtonDisabled=false;
$scope.resultMessage='失败:(请填写所有字段';
$scope.result='bg-danger';
}
}
});
当然:
测试控制器窗体的联系窗体{titulo}}
名称
电子邮件
主题
消息
发送消息

{{{resultMessage}


视图正常,因此您可以在$http承诺中添加错误,并查看服务器响应。

检查您的web服务器访问日志,并在PHP中添加一些日志记录;这样您将看到请求的内容。对于我的,日志中没有任何内容。如果我尝试原始文件,它会工作,并且我会在日志中看到我发送的表单。我相信是为了这个目的呼叫请求表单有问题,或者我的控制器不好,或者因为我使用ng view访问文件夹模板contact.html而发生了一些事情。因此,请从工作代码开始,在新代码的各个部分中进行交换,直到代码断开,然后您将知道问题所在。您能帮我更多忙吗?请提供您的邮件地址?大家好,有人可以告诉您我更多。我在检查表单时发出了警报…我看到了警报,但同样的问题,页面刷新而不发布任何内容。我相信这是因为我使用ng view进行呼叫控制
//Creo modulo y su nbre + establecer function routage
var AppSol = angular.module('AppSol', ['ngRoute']);

//Configure routage

    AppSol.config(function($routeProvider){

        $routeProvider

        //Indico links pages nav

        .when ('/',{
            templateUrl:'templates/home.html',
            controller:''

        })

        .otherwise ({
                    redirectTo:"/"
        })

        .when ('/Inicio',{
            templateUrl:'templates/home.html',
            controller:'MainCtrl'

        })  

        .when ('/Contacto',{
            templateUrl:'templates/contacto.html',
            controller:'ContactController'

        })  

        .when ('/Servicios',{
            templateUrl:'templates/servicios.html',
            controller:'ServCtrl'

        }); 

    });

        //Creo controller and lo injecto
        AppSol.controller ('MainCtrl', function($scope){

        //Probar que funciona con mensaje
        $scope.titulo="MY TITLE";


        });


        //Creo controller and lo injecto
        AppSol.controller ('ServCtrl', function($scope){

        //Probar que funciona con mensaje
        $scope.message='';
        $scope.titulo='SECOND TITLE'       

        });





        //Creo controller and lo injecto

        AppSol.controller ('ContactController', function ($scope, $http) {
        $scope.titulo='TEST1 CALL CONTACT CONTROLLER'   
        //$scope.result = 'Hidden'
        $scope.resultMessage='Test2 with Result control - I see this mensaje.';
        $scope.formData; //formData is an object holding the name, email, subject, and message
        $scope.submitButtonDisabled = false;
        $scope.submitted = false; //used so that form errors are shown only after the form has been submitted
        $scope.submit = function(contactform) {
            $scope.submitted = true;
            $scope.submitButtonDisabled = true;
            if (contactform.$valid) {
                $http({
                    method  : 'POST',
                    url     : 'http://exampledomain.net/test/js/contact-form.php',
                    data    : $.param($scope.formData),  //param method from jQuery
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  //set the headers so angular passing info as form data (not request payload)
                }).success(function(data){
                    console.log(data);
                    if (data.success) { //success comes from the return json object
                        $scope.submitButtonDisabled = true;
                        $scope.resultMessage = data.message;
                        $scope.result='bg-success';
                    } else {
                        $scope.submitButtonDisabled = false;
                        $scope.resultMessage = data.message;
                        $scope.result='bg-danger';
                    }
                });
            } else {
                $scope.submitButtonDisabled = false;
                $scope.resultMessage = 'Failed :( Please fill out all the fields.';
                $scope.result='bg-danger';
            }
        }
    });








            Of course:


            <div class="jumbotron" ng-app="AppSol">
            <div class="container">
            <div id="corte"></div>



            <div class="vertical-middle">
            <div class="container">
            <div class="panel panel-default">
            <div class="panel-heading">
            <h2 class="panel-title">Contact Form</h2>              <strong>{{titulo}} for test controller form</strong>
            </div>
            <div ng-controller="ContactController" class="panel-body">
            <form ng-submit="submit(contactform)" name="contactform" method="post" action="" class="form-horizontal" role="form">
            <div class="form-group" ng-class="{ 'has-error': contactform.inputName.$invalid && submitted }">
            <label for="inputName" class="col-lg-2 control-label">Name</label>
            <div class="col-lg-10">
            <input ng-model="formData.inputName" type="text" class="form-control" id="inputName" name="inputName" placeholder="Your Name" required>
            </div>
            </div>
            <div class="form-group" ng-class="{ 'has-error': contactform.inputEmail.$invalid && submitted }">
            <label for="inputEmail" class="col-lg-2 control-label">Email</label>
            <div class="col-lg-10">
            <input ng-model="formData.inputEmail" type="email" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email" required>
            </div>
            </div>
            <div class="form-group" ng-class="{ 'has-error': contactform.inputSubject.$invalid && submitted }">
            <label for="inputSubject" class="col-lg-2 control-label">Subject</label>
            <div class="col-lg-10">
            <input ng-model="formData.inputSubject" type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Subject Message" required>
            </div>
            </div>
            <div class="form-group" ng-class="{ 'has-error': contactform.inputMessage.$invalid && submitted }">
            <label for="inputMessage" class="col-lg-2 control-label">Message</label>
            <div class="col-lg-10">
            <textarea ng-model="formData.inputMessage" class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your message..." required></textarea>
            </div>
            </div>
            <div class="form-group">
            <div class="col-lg-offset-2 col-lg-10">
            <button type="submit" class="btn btn-default" ng-disabled="submitButtonDisabled">
                Send Message
            </button>
            </div>
            </div>
            </form>
            <p ng-class="result" style="padding: 15px; margin: 0;">{{ resultMessage }}</p>
            </div>
            </div>
            </div>
            </div>