它在这里可用:http: //syllableapp.com/test
基本上,在 Safari、Chrome、Opera、Webkit Nightly 等中,该表单可以完美地按照预期工作。但是在 Firefox 中,提交它只是 ... 不做任何事情。为什么是这样?
这是我的 JavaScript:
$(document).ready(function() {
$('input[type="submit"]').click(function() {
event.preventDefault();
var email = $.trim($('.email').val());
var emailRegEx = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (email == "" || !emailRegEx.test(email)) {
$(this).effect("shake", { times:2 }, 75);
}
else {
var data = "email=" + email;
$.ajax({
type: "POST",
url: "register_email.php",
data: data,
success: function(data) {
if (data == 1) {
$('form').hide();
$('form').html("<p class='success'>You'll be notified! Welcome aboard.</p>");
$('form').fadeIn(300);
}
else {
$('form').hide();
$('form').html("<p class='error'>Dang, there was an error. <a href='mailto:me@christianselig.com'>Email me?</a></p>");
$('form').fadeIn(300);
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert("Error: " + errorThrown);
$('form').hide();
$('form').html("<p class='error'>Dang, there was an error. <a href='mailto:me@christianselig.com'>Email me?</a></p>");
$('form').fadeIn(300);
}
});
}
});
});
还有我的 PHP:
<?php
$db = new mysqli("localhost", "swuclu_emailer", "etreadmill:(", "swuclu_syllable_emails");
if ($db->connect_error) {
echo "0";
}
else {
$email = $_POST["email"];
$stmt = $db->prepare("INSERT INTO emails (email) VALUES (?)");
$stmt->bind_param("s", $email);
$stmt->execute();
echo 1;
}
?>
Firefox 以外的所有浏览器都可以正常工作的具体情况是什么?