Ajax成功后刷新页面 [英] refresh the page after ajax success

查看:117
本文介绍了Ajax成功后刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

This script is part of my site, why not refresh the page?

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

I tested other methods available on the stackoverflow but did not answer.

帮帮我,谢谢

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


            }
        });
    }
));

});

推荐答案

尝试一下

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

});

这篇关于Ajax成功后刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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