Reputation: 18235
Sometimes, if we post a form in page A
(to page B
), then we refresh the page B
.
<!-- page A -->
<form action="page-b.html" method="post">
<input type="text" name="data" />
</form
Then, when we try to refresh on page B
, we was prompt to confirm whether submit the POST data again.
So, I'm trying to find a way to detect whether it has some post data (or http method to be post) on page B
, something may looked like:
PS: jQuery is welcome
<!-- page B -->
<script>
if(window.has_post_data()) {
// do something in case
}
</script>
Upvotes: 1
Views: 593
Reputation: 4931
There is no way to accomplish that using pure javascript or jquery. Javascript has no record of the HTTP method used to load the page. The best way to work around this issue would involve having the server add some specific variable or markup if the method was post, and search for that variable or markup using javascript.
Upvotes: 2