1
我试图找出如何整合谷歌隐形reCaptcha到submit.js(ajax)附加的自定义提交表单。 感谢这 Implement the new Invisible reCaptcha from Google 我使用成功谷歌99%的网站隐形recaptcha。 我尝试遵循相同的指南,但是当我尝试在submit.js(ajax)调用之前添加到listing.php中时,一切正常,但如果用户提交了一些错误(忘记了某些字段),则值不会像以前一样保存。这里是submit.js(阿贾克斯)谷歌隐形recaptcha,wordpress,ajax,保存数据
jQuery('#lp-submit-form').submit(function(e){
$this = jQuery(this);
$this.find('.preview-section .fa-angle-right').removeClass('fa-angle-right');
$this.find('.preview-section .fa').addClass('fa-spinner fa-spin');
var fd = new FormData(this);
fd.append('action', 'listingpro_submit_listing_ajax');
jQuery.ajax({
type: 'POST',
url: ajax_listingpro_submit_object.ajaxurl,
data:fd,
contentType: false,
processData: false,
success: function(res){
var resp = jQuery.parseJSON(res);
if(resp.response==="fail"){
jQuery.each(resp.status, function (k, v) {
if(k==="postTitle"){
jQuery("input:text[name='postTitle']").addClass('error-msg');
}
else if(k==="gAddress"){
jQuery("input:text[name='gAddress']").addClass('error-msg');
}
else if(k==="category"){
jQuery("#inputCategory_chosen").find('a.chosen-single').addClass('error-msg');
jQuery("#inputCategory").next('.select2-container').find('.selection').find('.select2-selection--single').addClass('error-msg');
}
else if(k==="location"){
jQuery("#inputCity_chosen").find('a.chosen-single').addClass('error-msg');
jQuery("#inputCity").next('.select2-container').find('.selection').find('.select2-selection--single').addClass('error-msg');
}
else if(k==="postContent"){
jQuery("textarea[name='postContent']").addClass('error-msg');
}
else if(k==="email"){
jQuery("input#inputEmail").addClass('error-msg');
}
});
var errorrmsg = jQuery("input[name='errorrmsg']").val();
$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
$this.find('.preview-section .fa').addClass('fa-times');
$this.find('.preview-section').find('.error_box').text(errorrmsg).show();
}
else if(resp.response==="failure"){
jQuery("input#inputEmail").addClass('error-msg');
jQuery("input#inputEmail").after(resp.status);
$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
$this.find('.preview-section .fa').addClass('fa-angle-right');
}
else if(resp.response==="success"){
$this.find('.preview-section .fa-spinner').removeClass('fa-times');
$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
$this.find('.preview-section .fa').addClass('fa-check');
var redURL = resp.status;
function redirectPageNow(){
window.location.href= redURL;
}
setTimeout(redirectPageNow, 1000);
}
},
error: function(request, error){
alert(error);
}
});
e.preventDefault();
});
任何想法?谢谢,如果你可以给我一些提示,IM在一个完整的噩梦:D
另一个问题>听起来像使用本指南(https://stackoverflow.com/questions/41079335/implement-the-new-invisible-recaptcha-from-google)我可以实现谷歌recaptcha呈现,但其无用阿贾克斯,因为你有一个重定向:( –