admin管理员组文章数量:1318563
I create plugin to create wizards using jquery steps. I save all step's values into variable and using ajax to process it, then show using wp ajax function
but only one variable in ajax inserted into wp ajax function, other one value empty but when I see inside console log after ajax success. it have have value.
only variable answer
have value but results_wizard
don't have value.
var answer = [], results_wizards = [],
stepsWizard = jQuery("#wizard").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft",
enablePagination: false,
titleTemplate: "#title#",
onStepChanged: function (event, currentIndex, priorIndex) {
$('html, body').animate({
scrollTop: $("#row-wizard-letselschade").offset().top - 80
});
$('input[name="wiz-'+priorIndex+'"]:checked').each(function(i){
if(jQuery.inArray($(this).val(),answer) == -1){
// the element is not in the array
answer.push($(this).val());
results_wizards[$(this).val()] = $("label[for='"+this.id+"']").text();
};
});
$("input:checkbox:not(:checked)").each(function(i){
var removeItem = $(this).val();
answer = jQuery.grep(answer, function(value) {
return value != removeItem;
});
});
},
onFinished: function (event, currentIndex)
{
$('input[name="wiz-'+currentIndex+'"]:checked').each(function(i){
if(jQuery.inArray($(this).val(),answer) == -1){
// the element is not in the array
answer.push( $(this).val());
};
});
var dataAnswerNew = {
'action': 'wizard_answers',
'answer':answer,
'results_wizards': results_wizards,
};
$.post(whwz_ajaxurl, dataAnswerNew, function(response){
console.log(results_wizards);
$('.wizard-answer').html(response);
var form_id = $('.wpcf7').attr('id');
$('.wpcf7 > form').attr('action', '/#' + form_id);
wpcf7.initForm( jQuery('.wpcf7-form') );
});
}
});
here my ajax
var dataAnswerNew = {
'action': 'wizard_answers',
'answer':answer,
'results_wizards': results_wizards,
};
$.post(whwz_ajaxurl, dataAnswerNew, function(response){
console.log(results_wizards);
$('.wizard-answer').html(response);
var form_id = $('.wpcf7').attr('id');
$('.wpcf7 > form').attr('action', '/#' + form_id);
wpcf7.initForm( jQuery('.wpcf7-form') );
});
本文标签: pluginsCannot pass value variable to WP AJAX functions
版权声明:本文标题:plugins - Cannot pass value variable to WP AJAX functions 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742048405a2417929.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论