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

标签 javascript jquery ajax smart-wizard

如果 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/

相关文章:

javascript - TypeScript - 检查给定的 'any' 参数是否为自定义类型?

javascript - 如何在(作为)peerDependency 下安装包?

php - 需要有关使用 Valums ajax 上传脚本上传文件的帮助

javascript - FabricJS 中的文本颜色叠加

javascript - datepicker valid() 函数检查日期是否有效

xml - AJAX/Jquery XML 解析

php - 需要使用 SQL 查询设计网站搜索方面的帮助

javascript - JQuery SlideToggle 向下滑动,然后向上滑动以覆盖内容

ajax - 500 错误甚至请求渲染 HTML 代码

php - 按钮上的 AJAX 功能第一次点击后不运行 PHP