Created
January 22, 2017 09:46
-
-
Save Kcko/441ea984df968ae7324e1b22441f89db to your computer and use it in GitHub Desktop.
jQuery - Array of GET variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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