I got my query string in document. ready but then I want to remove it and save value in a global variable without refreshing the page, but it just never happens..
var globalVar = null;
$(document).ready(function () {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
results == null ? null : decodeURIComponent(results[1].replace(/\+/g, " "));
if (results != null)
globalVar = results[1];
window.location.search = '';
});
This code keeps reloading page forever
Edit
Here is what is happening,
User gets email to a link, to select right row in table on the site, we are using querystring as using hash doesn't work (TMG server removes it), so once user gets on the site, we don't need query string anymore as we are using hash (because hash don't refresh page on change.)
Edit 2
Why don't want to keep query string and hash ?
because I can update hash without refresh whereas updating querystring refreshes the page :(, so i don't want it to be like
www.example.com/sites/fruitstore?fruitid=123#fruitid=432