JavaScript location.reload() is losing post data

2019-02-17 16:54发布

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

7条回答
Ridiculous、
2楼-- · 2019-02-17 17:40

This was a complete hack, but necessary and allowed it to work with Safari. So at the end of the page I pushed all the post data into a session

$_SESSION['post'] = $_POST

I then used jQuery to update the session variables. Then used location.reload(); to reload the page once I was completed making changes and the as the page loads I simple pushed all session data back into post.

$_POST = £_SESSION['post'];

The result is the same as if a form was submitted.

查看更多
登录 后发表回答