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();
}
this is the javascript code which I am using to reload the page onchange
You can try this:
This is a known bug in Chrome. The issue is that Chrome doesn't do a POST when you reload via JavaScript. If you did that using the reload button, it would behave properly and ask the user if he wants to repost the data.
All the details are here: http://code.google.com/p/chromium/issues/detail?id=6429 [Edit: related bug] https://bugs.webkit.org/show_bug.cgi?id=23735
PLEASE STAR THIS BUG SO THAT IT GETS FIXED FASTER.
window.location.reload()
issues aGET
, so yes, thePOST
data will be lost.The only ways you can issue a post are either:
Use AJAX to post the data back, get the new page, and replace your body element with it, or
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 callform.submit()
I solved the problem in this way:
Just a little bit complicated, but it works. Hope this can help! Best, Luca.
I think you need to re-POST not re-load, as in HTTP POST rather than HTTP GET.
location.reload
does not supposed to post any data. If you need to send your data back to server consider submitting the form withmethod='post'
(if you have one), or use AJAX (e.g.jQuery.post
)