Is it possible to detect the HTTP request method (e.g. GET or POST) of a page from JavaScript? If so, how?
The primary or most commonly-used HTTP methods are POST, GET, PUT, PATCH, and DELETE.
The most commonly used HTTP request methods are GET, POST, PUT, PATCH, and DELETE.
The two most common HTTP methods are: GET and POST.
An HTTP request is made by a client, to a named host, which is located on a server. The aim of the request is to access a resource on the server. To make the request, the client uses components of a URL (Uniform Resource Locator), which includes the information needed to access the resource.
In a word - No
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 htmlentities($_SERVER['REQUEST_METHOD']); ?>"> <script type="text/javascript"> alert(document.getElementById("request-method").content); </script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With