使用 AJAX 单击按钮时在 html 中显示 "Thank you" 消息

Display "Thank you" message in html on click of button using AJAX

我正在尝试填写电子邮件提交表单。

我想在提交表单时(点击提交按钮时)显示感谢信息

这是我在 index.html fie

中的当前代码

我不想window这样的提醒

我想通过显示 "Thank you" 消息来隐藏邮箱和订阅按钮。

function call_mailm() {

  $.ajax({
    url: "http://google.com/form/" + $("#name").val(),
    success: function(result) {
      alert("Mail sent successfully");

    },
    error: function(error) {
      alert("There is some problem with mail");
    }
  });
  return false;

}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Begin  Signup Form -->
<div id="mc_embed_signup">

  <form>

    <input type="text" id="name" name="email" class="required email" id="email" placeholder="Email Address" style="font-size:15pt;height:38px;width:350px;font- family:Century Gothic;">

    <div style="position: absolute; left: -5000px;" aria-hidden="true">
      <input type="text" name="b_438e8df85b7f9df7fce94287a_013c74a5bc" tabindex="-1" value="">
    </div>
    <button onclick="return call_mailm()" value="Submit" name="subscribe" id="mc-embedded-subscribe" class="button" style="background-color: rgba(14,46,71,1);border: 1px solid #0E2E47;width:150px;height:37px;font-family: ‘Palatino Linotype’, ‘Book Antiqua’, Palatino, serif;font-size:24px;color:white;">Subscribe</button>
    <div id="mce-responses" class="clear">
      <div class="response" id="error" style="display:none"></div>
      <div class="response" id="success" style="display:none"></div>
    </div>
  </form>

</div>
<!--End mc_embed_signup-->

像这样的标签内部

<div id="success">
Congrats! <br>
 Thank you for subscribing
 </div>

添加新的 div 以及感谢消息和 delete/hide 表格。最简单的例子:

$.ajax({url: "http://google.com/form/"+$("#name").val(), 
    success: function(result){
      $('#mc_embed_signup').html('<div>Thank you!</div>');

    },
    error: function (error) {
      alert("There is some problem with mail");
    }
  });