gpt4 book ai didi

javascript - ajax成功后如何在智能向导中前进

转载 作者:行者123 更新时间:2023-11-30 08:21:25 26 4
gpt4 key购买 nike

如果 ajax 调用成功,我想转到下一步,但我无法在 ajax 调用中调用智能向导方法。我的代码在这里。

var wizard = $("#listing_wizard").smartWizard({onLeaveStep:stepSubmit});

//stepsubmit
function stepSubmit(){
var that = this;
//that.goForward ------- working here
var step_no = this.curStepIdx+1;
var form_data = $("#step_"+step_no+"_form").serialize();

$.ajax({
type:'post',
url:"<?php echo URL_ADMIN ?>ajax.php",
data:form_data,
success:function(data){
return that.goForward; //not working here
}
});
}

I think the problem is here in these "this" so how can I call the smart wizard this.goForward after ajax call

最佳答案

如果您使用的是最新的 Smart Wizard v4 ,这是解决方法。

$('#listing_wizard').smartWizard();

$("#listing_wizard").on("leaveStep", function(e, anchorObject, stepNumber, stepDirection) {

var form_data = $("#step_"+ stepNumber +"_form").serialize();

$.ajax({
type:'post',
url:"<?php echo URL_ADMIN ?>ajax.php",
data:form_data,
success:function(data){
// indicate the ajax has been done, release the next step
$("#listing_wizard").smartWizard("next");
}
});

// Return false to cancel the `leaveStep` event
// and so the navigation to next step which is handled inside success callback.
return false;

});

这已在 How to wait ajax done to process next step? 上解决
另请参阅文档 jQuery Smart Wizard 4: Documentation

关于javascript - ajax成功后如何在智能向导中前进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52995998/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com