我有一个wordpress表单,它是使用联系表单7构建的。我有一个要求,当选中复选框时,我必须将用户的电子邮件和名称发送到comapign监视器列表,同时联系表单发送一封电子邮件。
<form action="/xxx/xxx/#wpcf7-f54-o3" method="post" class="wpcf7-form" enctype="multipart/form-data" novalidate="novalidate">
<div style="display: none;">
<input type="hidden" name="_wpcf7" value="54">
<input type="hidden" name="_wpcf7_version" value="3.8.1">
<input type="hidden" name="_wpcf7_locale" value="en_US">
<input type="hidden" name="_wpcf7_unit_tag" value="wpcf7-f54-o3">
<input type="hidden" name="_wpnonce" value="96b9aa989f">
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
<span class="wpcf7-form-control-wrap text-482"><input type="text" name="text-482" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" id="name" aria-required="true" aria-invalid="false" placeholder="Your Name (required)"></span>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
<span class="wpcf7-form-control-wrap text-742"><input type="text" name="text-742" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false" placeholder="Your Phone (required)"></span>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
<span class="wpcf7-form-control-wrap email-160"><input type="email" name="email-160" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" id="email" aria-required="true" aria-invalid="false" placeholder="Your Email (required)"></span>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<span class="wpcf7-form-control-wrap your-message"><textarea name="your-message" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea" aria-invalid="false" placeholder="Your Message"></textarea></span>
</div>
<div class="col-md-4 col-sm-6 col-xs-12>
<span class=" wpcf7-form-control-wrap="" file-469"=""><input type="file" name="file-469" value="1" size="40" class="wpcf7-form-control wpcf7-file" aria-invalid="false">
</div>
<div class="col-md-4 col-sm-6 col-xs-12>
<span class=" wpcf7-form-control-wrap="" acceptance-212"=""><input type="checkbox" name="acceptance-212" value="1" class="wpcf7-form-control wpcf7-acceptance" id="newsletter" checked="checked" aria-invalid="false"> Get Our Newsletter
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
<input type="submit" value="Send message" class="wpcf7-form-control wpcf7-submit submitBnt"><img class="ajax-loader" src="http://x.x.x.x/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Sending ..." style="visibility: hidden;">
</div>
<p><br></p>
<div class="clearfix"></div>
<div class="wpcf7-response-output wpcf7-display-none"></div></form>
JS档案
// Contact form
$('.wpcf7-form').submit(function(e){
e.preventDefault();
var email = $('#email').val();
var name = $('#name').val();
var url ='http://myaccount.createsend.com/t/t/s/dylulk/';
if($("#newsletter").is(':checked')) {
$.ajax({
type : "POST",
// dataType: "json",
url: url,
data:'cm-dylulk-dylulk='+email+'&cm-name='+name
});
}
});
单击“提交”按钮后,表单会毫无问题地发送电子邮件,但“发布”请求无法将电子邮件和名称发送到活动监视器列表。我错过了什么步骤?