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呈現,但其無用阿賈克斯,因爲你有一個重定向:( –