Is it possible to detect the HTTP request method (e.g. GET or POST) of a page from JavaScript? If so, how?
+1
A:
You cant do this for a normal post/get however you can get to this info if you use an xmlhttp call and use the getResponseHeader
redsquare
2008-09-23 14:11:36
+1
A:
If you need this functionality, have the server detect what method was used and then modify something in the DOM that you can then read out later.
Daniel Papasian
2008-09-23 14:20:50
+2
A:
I don't believe so. If you need this information, I suggest including a <meta>
element generated on the server that you can check with JavaScript.
For example, with PHP:
<meta id="request-method" name="request-method" content="<?php echo($_SERVER['REQUEST_METHOD']); ?>">
<script type="text/javascript">
alert(document.getElementById("request-method").content);
</script>
Jim
2008-09-23 14:21:38