问题
I want to go to the next step if the ajax call is successful, but i am not able to call the smart wizard methods inside the ajax call. My code is here.
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
回答1:
If you are using the latest Smart Wizard v4, here is the workaround.
$('#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;
});
This is already addressed on How to wait ajax done to process next step?
Also refer the documentation jQuery Smart Wizard 4: Documentation
来源:https://stackoverflow.com/questions/52995998/how-to-go-forward-in-smart-wizard-after-ajax-success