我的网站上有两种表格。他们都接受电子邮件地址,两者的代码是相同的。第一种形式工作正常,但我在第二种形式上得到XMLHTTPRequest失败错误。这是为什么?
这是错误:
Could not accept email address: XMLHttpRequest failed: {"statusText":"","status":0,"response":"","responseType":"","responseXML":null,"responseText":"","upload":{"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null},"withCredentials":false,"readyState":4,"timeout":0,"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null}
以下是代码:
HTML:
<section class="subscribe2">
<div class="container">
<div class="row">
<form>
<div class="col-sm-8">
<input type="text" class="subinput" placeholder="Enter your email for updates" spellcheck="false">
</div>
<div class="col-sm-4">
<button class="btn-primary" type="submit">
Subscribe now
</button>
</div>
</form>
</div>
</div>
</section>
JS:
$(".button-large").click(function() {
console.log("Notify Me");
var emailAdd = $(".input").val();
if (emailAdd.length <5) {
alert("Please enter a valid email address.");
} else {
var Address = $(".input").val();
var Email = Parse.Object.extend("Email");
var email = new Email();
email.set("Address", Address);
console.log(Address);
email.save(null, {
success: function(email) {
console.log('New object created with objectId: ' + email.id);
},
error: function(email, error) {
console.log('Could not accept email address: ' + error.message);
alert("Error")
}
});
}
});