我正在尝试构建订阅表单。我无法在我的网站上运行PHP,并且我不希望用户离开主站点订阅通讯。我正在使用this example as server side。 如果您尝试向您发送电子邮件,您将收到重定向,即使电子邮件已添加到mailchimp列表中,也会显示错误消息。Ajax不显示服务器响应
<div id="email">
<span>Your email..</span>
<form action="http://simondahla.com/jolliassets/notify.php" id="notify" method="POST">
<input type="text" placeholder="[email protected]" name="email" id="address" data-validate="validate(required, email)"/>
<span>We'll never spam or give this address away</span>
<button type="submit">»</button>
</form>
<span id="result"></span>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#notify').submit(function() {
var action = $(this).attr('action');
$.ajax({
url: action,
type: 'POST',
data: {
email: $('#address').attr('value')
},
success: function(data){
$('#result').html(data).css('color', 'green');
},
error: function() {
$('#result').html('Sorry, an error occurred.').css('color', 'red');
}
});
});
});
</script>
[途径可能重复绕过同源政策](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy) – Quentin
Wher e是实际添加到mailchimp的代码? –