联系表格不发送邮件

时间:2018-07-28 23:55:09

标签: php jquery forms contact

我需要此联系表的帮助。我已经尝试了所有可能的发送方法,但是无法正常工作。当您在表单上填写所有详细信息,然后按发送时,该表单将清除,仅此而已,什么也没有发生。我选中了应该发送至详细信息的电子邮件框,但那里什么也没有。我已经更改了jQuery上的电子邮件地址,而且我已经检查了几次代码,但是没有任何效果。

<read-more 
     [text]="course?.description | highlight : searchText" 
     [maxLength]="100"
     [query]="searchText"> </read-more>


<form>
  <br>
  <div class="form-row">
  <form action="/action_page.php" method="post" id="reused_form">
    <script src='https://www.google.com/recaptcha/api.js'></script>

    <div id="success_message" style="width:100%; height:100%; display:none; ">
      <h3>Sent your message successfully!</h3>
    </div>
    <div id="error_message" style="width:100%; height:100%; display:none; ">
      <h3>Error</h3>
      Sorry there was an error sending your form.
    </div>


$(function(){
  function after_form_submitted(data){
    if(data.result == 'success'){
      $('form#reused_form').hide();
      $('#success_message').show();
      $('#error_message').hide();
    }else{
      $('#error_message').append('<ul></ul>');

      jQuery.each(data.errors,function(key,val){
        $('#error_message ul').append('<li>'+key+':'+val+'</li>');
      });
      $('#success_message').hide();
      $('#error_message').show();

      //reverse the response on the button
      $('button[type="button"]', $form).each(function(){
        $btn = $(this);
        label = $btn.prop('orig_label');
        if(label){
          $btn.prop('type','submit' );
          $btn.text(label);
          $btn.prop('orig_label','');
        }
      });

    }//else
  }

  $('#reused_form').submit(function(e){
    e.preventDefault();

    $form = $(this);

    $('button[type="submit"]', $form).each(function(){
      $btn = $(this);
      $btn.prop('type','button' );
      $btn.prop('orig_label',$btn.text());
      $btn.text('Sending ...');
    });


    $.ajax({
      type: "POST",
      url: 'handler.php',
      data: $form.serialize(),
      success: after_form_submitted,
      dataType: 'json'
    });

   });
 });

0 个答案:

没有答案
相关问题