Retrieving the GET and POST superglobal headers in Javascript is actually very easy, although most of us are spoiled by the method used by PHP ($_GET and $_POST).
Although it takes a few more lines of code, you can mimic PHP.
How To Get $_GET in Javascript
var $_GET = {}; document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { function decode(s) { return decodeURIComponent(s.split("+").join(" ")); } $_GET[decode(arguments[1])] = decode(arguments[2]); });
You can now access the $_GET variables like so:
alert($_GET['some_variable']);
How To Get $_POST in Javascript
$_POST is handled a little differently (with the help of PHP). This cross-language fix allows you to store the PHP superglobal $_POST into a Javascript variable. You can also use this method for $_GET.
<script> var $_POST = ; document.write($_POST["test"]); </script>
Happy coding!