Today I needed to get the page's request parameters into a associative array so I put together the following, with a little help from myfriends. It also handles parameters without an = as true.
You can use the URL to acquire the GET variables. In particular, window.location.search gives everything after (and including) the '?'. You can read more about window.location here.
Today I needed to get the page's request parameters into a associative array so I put together the following, with a little help from my friends. It also handles parameters without an
=
astrue
.With an example:
The function here returns the parameter by name. With tiny changes you will be able to return base url, parameter or anchor.
Just to put my two cents in, if you wanted an object containing all the requests
Note, the key for each get param is set to lower case. So, I made a helper function. So now it's case-insensitive.
You could use
jquery.url
I did like this:Check the source code
Updated Source: https://github.com/allmarkedup/jQuery-URL-Parser
Works for me in
url: http://localhost:8080/#/?access_token=111
You can use the URL to acquire the GET variables. In particular,
window.location.search
gives everything after (and including) the '?'. You can read more about window.location here.