ajax成功后刷新页面

时间:2016-06-09 06:23:48

标签: jquery ajax ajaxform

此脚本是我网站的一部分,为什么不刷新页面?

我测试了stackoverflow上可用的其他方法但是 没有回答。

帮助我,谢谢

$(document).ready(function (e) {
    $("#loginform").on('submit',(function(e) {

    var show_result_ajax = $("#show-result-ajax-loginform");

        e.preventDefault();
        $.ajax({
            url: "inc/custom/login.php",
            type: "POST",
            data: new FormData(this),
            contentType: false,
            cache: false,
            processData:false,
            success: function(data)
            {

                if(data != 'empty_error'){
                   show_result_ajax.fadeOut(function(){
                          show_result_ajax.html(data);
                   });
                   show_result_ajax.fadeIn();
                }
                else
                if(data == 'empty_error'){
                    window.location.reload();
                }


            }
        });
    }
));

});

1 个答案:

答案 0 :(得分:2)

试试这个

$(document).ready(function (e) {
    $("#loginform").on('submit',(function(e) {

        e.preventDefault();

        var show_result_ajax = $("#show-result-ajax-loginform");

        $.ajax({
            url: "inc/custom/login.php",
            type: "POST",
            data: new FormData(this),
            contentType: false,
            cache: false,
            processData:false,
            success: function(data)
            {
                if(data != 'empty_error'){
                    show_result_ajax.fadeOut(function(){
                        show_result_ajax.html(data);
                    });
                    show_result_ajax.fadeIn();
                }
                else if(data == 'empty_error'){
                    location.reload();
                }
            }
        });

        return false;
    }));

});
相关问题