I have a url like /accounts/?status=done
So on load of the document i want to get the current url
and GET data
like status=done
so below is my code which can able to get the current url, but not the GET data
<script>
$(window).load(function() {
//alert("window load occurred!");
var pathname = window.location.pathname;
console.log(pathname);
$.get(pathname,function(data){ console.log(data) });
});
</script>
So how to get the current url and GET data like ?status=done in jquery on loading of page ?
Edit
So i have edited according to the link provided here as below and still its unable to print the query string parameters
<script>
function getParameterByName(name) {
console.log(name+"......................");
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
$(window).load(function() {
//alert("window load occurred!");
var pathname = window.location.pathname;
console.log(pathname+"hurayyyyy");
console.log(pathname);
var res = getParameterByName(window.location.pathname)
console.log(res+"oooppppppppppppssssssssssss");
});
</script>
The results was just like below