Bootstrap向导不会移动到下一页

时间:2016-11-29 12:23:51

标签: jquery ajax

我目前正在为我的ajax请求使用bootstrapWizard插件寻求帮助。当表单成功提交时,它不会移动到表单中的下一页。有人可以通过我的以下代码帮助我找出原因。当表单提交时,它确实在响应中将成功键设置为true,因此它正确返回。

$("#pageOneSubmission").click(function() {
    ...
    $.ajax({
        type: "POST",
        url: '{{ route('...') }}',
        data:
            {
                ...
            },
        dataType: JSON,
        success: function(data) {
            if (!data.success) {
                console.log("Errors");
                $('#orderForm').bootstrapWizard({onTabClick: function(tab, navigation, index) {
                    alert('on tab click disabled');
                    return false;
                }});
            } else {
                $('#orderForm').bootstrapWizard({onTabClick: function(tab, navigation, index) {
                    nextTab($('.wizard .nav-tabs li.active'));
                }});
                console.log("No Errors");
                alert('no errors');
                swal({
                    title: "Success!!",
                    text: "Your order & patient profile are saved!",
                    timer: 2500,
                    showConfirmButton: false,
                    type: "success"
                });



            }
        },
        error: function(jqXhr) {
            if (jqXhr.status === 422) {
                alert('testing with errors');
                var err = JSON.parse(jqXhr.responseText);
                // $('#orderForm').bootstrapWizard('disable', $('#step2').data('tabindex'));
                // this wouldn't work cause your redirecting the page, the loop
                // wouldn't loop...
                // window.location = $('#orderForm').attr('action');
                $.each(err, function(key, value) {
                // $('input [name="'+ key +'"]').next().append("<p>Test</p>");
                    $('#'+data.errors[I][0]+'').css({'border':'#F00'});
                });
            }
        }
    }, function(){
        setTimeout(function() {

        })
    });
});

0 个答案:

没有答案