【问题标题】:refresh the page after ajax successajax成功后刷新页面
【发布时间】:2016-10-09 15:41:06
【问题描述】:

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

我测试了 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();
                }


            }
        });
    }
));

});

【问题讨论】:

  • ajax 返回什么?
  • 嗨 Mohammad,数据是否提供了您的表达方式?你用控制台日志检查过吗?
  • 嗨@KamuranSönecek,是的

标签: jquery ajax ajaxform


【解决方案1】:

试试这个

$(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请求问题!
猜你喜欢
  • 1970-01-01
  • 2015-10-19
  • 2018-01-24
  • 1970-01-01
  • 2018-05-09
  • 2017-02-27
  • 2021-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多