Could someone help me to get the querystring in an array on page reload Here is an example of the querystring https://local.abc.com/?country=us&state=California&city=Los Angeles&city=abc Plan&city=xyz
I need to get the list of city from the querystring to further perform some action on the city list. Any input is appreciated.
CodePudding user response:
getting one code row from Get querystring from URL using jQuery here is result:
var cities = [];
var a = window.location.href.slice(window.location.href.indexOf('?') 1).split('&');
for (i in a) {
var n = a[i].split("=");
if (n[0].toUpperCase() == "CITY") {
cities.push(decodeURIComponent(n[1]));
}
}
console.log(cities);
cities is the array containing all cities from URI