JavaScript location.reload() is losing post data(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();
}
这是我用来在更改时重新加载页面的 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:
使用 AJAX 回传数据,获取新页面,并用它替换你的 body 元素,或者
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() 正在丢失发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JavaScript location.reload() 正在丢失发布数据
基础教程推荐
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
