JavaScript location.reload()正在丢失发布数据 [英] JavaScript location.reload() is losing post data

查看:95
本文介绍了JavaScript location.reload()正在丢失发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Java脚本重新加载页面,但页面重新加载,但是页面中未加载的帖子数据被删除,而页面重新加载时有人可以帮助我

I am trying to reload the page using java script the page reloads but the post data in the page is not loading the post data are deleted while the page reloads can any one help me with it

function currencychange(xxx) {
    setTimeout('delay()', 2000);
}
function delay(){
    location.reload();
}

这是我用来重新加载onchange页面的javascript代码

this is the javascript code which I am using to reload the page onchange

推荐答案

window.location.reload()发出GET,因此,POST数据将丢失.

window.location.reload() issues a GET, so yes, the POST data will be lost.

发布帖子的唯一方法是:

The only ways you can issue a post are either:

  1. 使用AJAX将数据回传,获取新页面并用它替换您的body元素,或者

  1. Use AJAX to post the data back, get the new page, and replace your body element with it, or

在页面上创建一个带有当前window.location.href动作的表单元素,然后将要发布的数据放回内部作为隐藏输入.然后,在货币更改时呼叫form.submit()

Create a form element on the page with the action being the current window.location.href, and place the data you want to post back inside it as hidden inputs. Then, on currency change call form.submit()

这篇关于JavaScript location.reload()正在丢失发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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