Friday, 2 May 2014

jquery query string parameters

jquery query string parameters


https://Myapp/home.aspx?ID=1&Sno=2


<script>
$(document).ready(function () {
var vars = [], hash;
var q = document.URL.split('?')[1];
//alert(q);
if (q != undefined) {
q = q.split('&');
for (var i = 0; i < q.length; i++) {
hash = q[i].split('=');
vars.push(hash[1]);
vars[hash[0]] = hash[1];
}
}
alert(vars['ID']);
alert(vars['Sno']);
});
</script>