Как и в заголовке - я пытаюсь заставить мою форму сбора электронной почты на моей веб-странице stati c работать во время хостинга на AWS.
HTML:
<form id="email-submit" method="post">
<div class="container-fluid">
<div class="row justify-content-end">
<div class="col-lg-6">
<div class="call-action-content text-center">
<h2 class="call-title">Want early access?</h2>
<p class="text">Enter your email below to gain priority access and to receive updates on the official release.</p>
<div class="call-newsletter">
<i class="lni-envelope"></i>
<input type="email" id="email-input" placeholder="Email address">
<button type="submit" onClick="submitToAPI2(event)">Stay informed</button>
И jquery / ajax, который я нашел в документации Amazon, которую я использую:
function submitToAPI2(e) {
e.preventDefault();
var URL = "the api gateway";
var reeamil = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!reeamil.test($("#email-input").val())) {
alert ("Please enter a valid email address");
return;
}
var email = $("#email-input").val();
var data = {
email : email
};
$.ajax({
type: "POST",
url : "api gateway",
dataType: "json",
crossDomain: "true",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
success: function () {
// clear form and show a success message
alert("Successfull");
document.getElementsById("email-submit").reset();
location.reload();
},
error: function () {
// show an error message
alert("Error. Please try again");
}});
}
Есть идеи, почему она не работает?