Wednesday 26 September 2018

get query string using jquery.

    <script type="text/javascript">
        function GetParameterValues(param) {
            var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < url.length; i++) {
                var urlparam = url[i].split('=');
                if (urlparam[0] == param) {
                    return urlparam[1];
                }
            }
        }
    </script>
    <script type="text/javascript">//use of function
        var name = GetParameterValues('PSID'); //PSID is query string name.

                  if (typeof name === "undefined")
                     {
                                var pid=data.Product;
                                if(isNaN(id))
                                pid=0;
                                if (pid > 0)
                                getlastpurprice(id,pid);
                     }
    </script>