<script type="text/javascript">
jQuery(document).ready(function($) {
//Send email on form submission
$('#contact-form').submit(function(e){
var name = $('#name').val();
var email = $('#email').val();
var message = $('#message').val();
if(name==='' || email==='' || message ===''){
return false
}
else{
e.preventDefault();
console.log("success");
$.ajax({
url: "https://formspree.io/xyz@gmail.com",
method: "POST",
data: {
name: name,
email: email,
message : message
},
dataType: "json" });
}
})
});
</script>
html表单
<form method="POST" id="contact-form">
<input type="text" name = "name" id="name" placeholder="Name" required>
<input type="email" name="email" id="email" placeholder="Email" required>
<textarea id="message" name="message" placeholder="Message..." required></textarea>
<input type="submit" value="Send">
</form>
我不知道我做错了什么,我的数据没有被发送。 我的formspree都已设置完毕。有人可以帮我这个吗?问题看起来很小但是无法通过