需要帮助让放大器形式工作

时间:2017-10-11 19:30:34

标签: amp-html

我正在为客户端设置放大器设置,我已经在这里设置了样式:

<form name="AMPform"
method="post"
action-xhr="blank"
target="_top">
<div><label for="name"></p> <h4>Name:</h4> <p></label><br />     <input type="text"       name="firstname"       placeholder="First"       required>
<input type="text" name="lastname" placeholder="Last" required><br /></p>
<h4>Address:</h4> 
<p><input type="text" name="streetaddress" placeholder="Street Address" required></p>
<p><input type="text" name="addressline2" placeholder="Address Line 2"></p>
<p><input type="text" name="city" placeholder="City" required>
<input type="text" name="stateprovinceregion" placeholder="State/Province/Region" required></p>
<p><input type="text" name="zip" placeholder="ZIP / Postal Code" required>
<input type="text" name="country" placeholder="Country" required><br /></p> 
<h4>Contact Information:</h4>
<p><input type="email" name="email" placeholder="Email..." required></p>
<p><input type="tel"  name="telephone" placeholder="Telephone..."><br /></div>
<div><br /><label for="help">What can we help you with?</label><br /><br />
<select name="help" id="help"><option value="neuro">Brain Training/Neurofeedback</option><option value="concussion">Concussion/Brain Injury/Brain Trauma</option><option value="add">ADD/ADHD/Autism/MS/PD/Stroke</option><option value="forensic">Forensic Consultant and Expert Testimony</option><option value="sports">Sports/Performing Arts Psychology</option><option value="education">Education/Training</option><option value="other">Other</option></select></p>
<p><label for="hear about us">How did you hear about us?</label><br /><br />
<select name="hear-about-us" id="hear about us"><option value="referral">Referral (Clinician/Professional)</option><option value="psychologytoday">Psychology Today Blog</option><option value="internet">Internet/Website</option><option value="books">Book(s)</option><option value="workshop">Workshop/Speech</option><option value="newsletter">Newsletter</option><option value="other">Other</option></select></p>
<p><textarea name="message" placeholder="Comments/Questions" required></textarea></div>
<p></p><div><input type="submit" value="Submit" class="button"></div><br />
&nbsp;
&nbsp;
<br /> 
<div submit-success><template type="amp-mustache"><br />Thank you for contacting us, we will get back to you shortly.<br /></template></div>
<div submit-error><template type="amp-mustache"><br />Something went wrong, please try again later.<br /></template></div></p></form><br />

我需要弄清楚如何制作一个动作-xhr,以便在按下提交按钮时,所有表格信息都会通过电子邮件发送给我的客户,但我不确定如何正确设置。

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

所以这就是你需要做的事情:

  1. 包含放大器形式脚本
  2. 将action-xhr属性设置为后端网址
  3. 您的后端应返回Content-Type: application/json
  4. 的JSON响应
  5. 后端应返回200状态代码表示成功,400表示错误。
  6. 您返回的JSON对象将分别在submit-success或submit-error容器中呈现。
  7. 这真的很简单。