Windows.history.back()+ location.reload()jQuery [英] Windows.history.back() + location.reload() jquery

查看:219
本文介绍了Windows.history.back()+ location.reload()jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码有问题.目的是完成一个简单的表单,然后单击提交"按钮.它执行Ajax请求进入该方法.在ajax请求成功后,我使用windows.history.back()转到上一页.在这里,我想刷新此页面,以刷新由表单修改的值!您对此有个想法吗?

I've a probleme in my code. The aim is to complete a simple form, then you click on a submit button. It do an Ajax resquest to go in the method. On success in the ajax request, i use windows.history.back() to go to the previous page ans here i want to refresh this page, to refresh values which are modificated by the form ! Have you an idea about that ?

    $('#form_edit').submit(function (e)
    {
        e.preventDefault();
        $.ajax({
            url: $('#form_edit').attr('action'),
            type: 'POST',
            cache: false,
            data: $(this).serialize(),
            success: function (data) {
                if (data === true) {
                    alert("Modification réussie !");
                    window.history.back();
                    location.reload(); <= on success i want to refresh previous page
                }
                else {
                    alert("Modification échouée !");
                }
            },
            error: function ()
            {
                alert("Modification échouée !");
            }
        })
    })

推荐答案

在执行重新加载之前它将已经返回.

It will have already gone back before it executes the reload.

您最好更换:

window.history.back();
location.reload(); 

具有:

window.location.replace("pagehere.html");

这篇关于Windows.history.back()+ location.reload()jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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