admin管理员组文章数量:1410717
I have in simulation.jsp the following code, by which I receive some simulation data from struts2 action:
$(document).ready(function() {
var data='<s:property escape="false" value="simInfos" />';
}
Now I do some simulation with this data. After the simulation has been done, how can I reload/refresh this page with button-click without losing this data, which I have received from struts2 action?
I have in simulation.jsp the following code, by which I receive some simulation data from struts2 action:
$(document).ready(function() {
var data='<s:property escape="false" value="simInfos" />';
}
Now I do some simulation with this data. After the simulation has been done, how can I reload/refresh this page with button-click without losing this data, which I have received from struts2 action?
Share Improve this question asked Apr 13, 2012 at 5:09 Max_SalahMax_Salah 2,50711 gold badges42 silver badges69 bronze badges 2- If it's a lot of data you need to use ajax to store and retrieve it from the server. – Erik Reppen Commented Apr 13, 2012 at 5:25
- use hiddenfield control to store variable value. – Rony SP Commented Apr 13, 2012 at 6:22
2 Answers
Reset to default 4$(document).ready(function() {
var data='<s:property escape="false" value="simInfos" />';
localStorage["myData"] = data;
// later on (maybe after page refresh, whatever)
var myLoadedData = localStorage["myData"];
}
You can treat HTML5's localStorage like any other object, although it has specific setter and getter functions and can only store strings. Don't treat it like a permanent cache though, just a place to store some data for a little while. Another reference.
You may want to use this Cross-browser local storage API: http://www.jstorage.info/
You can use it like how you use HTM5's localStorage ;D
$.jStorage.set("foo", "value"); //Set "value" in "foo"
var txt = $.jStorage.get("foo"); //"txt" is now "value"
本文标签: javascriptHow to reload the page without losing variables valueStack Overflow
版权声明:本文标题:javascript - How to reload the page without losing variables value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744832844a2627452.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论