如果 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
}
});
}
最佳答案
如果您使用的是最新的 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/