I am trying to create a web app that uses a zip code (passed from the previous page). The URL looks like /location#12345
I am trying to store everything after '#' in a variable to be used in the location finder app.
URL: /locations#12345
$(document).ready(function(){
var queryString = decodeURIComponent(window.location.search);
queryString = queryString.substring(1);
var queries = queryString.split("#");
var myVal;
for (var i = 0; i < queries.length; i++)
{
myVal = myVal + queries[i];
}
alert(myVal);
});
I thought alert(myVal) would produce "12345" but it is blank. There are no errors in the console.