I am trying to send an email by the static website via javascript API. Currently, I am able to send an email via post request. On clicking send email button I am redirected to that specific API link. I need help to redirect to my custom link and in the back-end, email shall be sent.
<html>
<script>
function email()
{
$.ajax({
type:"POST",
url:"https://formspree.io/MYEMAIL@SOMEMAIL.COM",
contentType:"application/json; charset=utf-8",
dataType:"json",
success:function(result){
alert(result.d);
console.log(result);
}
});
Location.href = "https://google.com";
}
</script>
<body>
<textarea name="message" placeholder="Your message"></textarea>
<button type="submit">Send</button>
</body>
</html>