1
我想创建一个表单,其中包含一个URL的操作。但它首先需要提交ajax,然后提交给action。阿贾克斯没有提交提交
它应该给我发电子邮件(在newsletter.php内)。
<script type='text/javascript'>
$(function() {
$("#signup").on('submit', function(e, response) {
if (response.errors == false) {
$.ajax({
type : 'GET',
url : 'newsletter.php',
data: {
name : $('#os0').val(),
email: $('#os1').val()
},
success : function(data) {
$('#subscribe').submit();
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
// error handling
}
});
return false;
}
return true;
});
});
</script>
HTML
<form name="signup" id="signup" action="" method="GET">
<input type="text" id="os0" name="Email" />
<input class="text" id="os1" type="text" name="cd_FULLNAME" />
<input type="Submit" name="Submit" id="subscribe" value="Subscribe" />
</form>
这将是无止境的循环。 – HaBo 2014-08-29 19:51:27
你的提交处理程序应该从哪里得到一个名为'response'的变量来自...? – CBroe 2014-08-29 19:51:38
什么是在这里做的“响应”?这将是'未定义'。检查这个小提琴:http://jsfiddle.net/karthikr12/c2m09dsk/(有防止默认动作) – karthikr 2014-08-29 19:52:22