RsD0p9BK
3/16/2015 - 8:02 AM

$_GET.js

// how to get GET and POST variables with JQuery

function getUrlVars() {
    var vars = [], hash, hashes = null;
    if (window.location.href.indexOf("?") && window.location.href.indexOf("&")) {
        hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    } else if (window.location.href.indexOf("?")) {
        hashes = window.location.href.slice(window.location.href.indexOf('?') + 1);
    }
    if (hashes !== null) {
        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars[hash[0]] = hash[1];
        }
    }
    return vars;
}

var $_GET; 
$_GET = getUrlParams();

// http://stackoverflow.com/questions/439463/how-to-get-get-and-post-variables-with-jquery