Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created January 22, 2017 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kcko/441ea984df968ae7324e1b22441f89db to your computer and use it in GitHub Desktop.
Save Kcko/441ea984df968ae7324e1b22441f89db to your computer and use it in GitHub Desktop.
jQuery - Array of GET variables
var searchArray = document.location.search.substring(1).split("&");
//Take off the '?' and split into separate queries
//Now we'll loop through searchArray and create an associative array (object literal) called GET
var GET = [];
for (var searchTerm in searchArray){
searchTerm.split("="); //Divide the searchTerm into property and value
GET[searchTerm[0]] = searchTerm[1]; //Add property and value to the GET array
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment