Ajax成功后如何在智能向导中前进 [英] How to go forward in smart wizard after ajax success

查看:144
本文介绍了Ajax成功后如何在智能向导中前进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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
        }
      });
    }

我认为问题出在这些"this"中,所以我怎么称呼智能向导ajax调用后的this.goForward

推荐答案

如果您使用的是最新的智能向导v4 ,这是解决方法.

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;

});

此问题已在如何等待ajax完成以处理下一步的问题上解决?
另请参阅文档 jQuery Smart Wizard 4:文档

This is already addressed on How to wait ajax done to process next step?
Also refer the documentation jQuery Smart Wizard 4: Documentation

这篇关于Ajax成功后如何在智能向导中前进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆