Reputation: 1636
I am trying to load the url of a search page by specifying both the path I want to load and the search parameters that should be appended.
For example I'm loading /foo/?q=1&a=2 I would try to type something in javascript like this:
location.href = /foo/?q=1&a=2
Then when that's run I get an invalid token exception at the '&' character. I'm well versed in javascript and jquery so I'm open to an answer in either language.
I just need to be able to set location.href and it's associated search parameter so that I can load the page correctly. OR if you have suggestions as to other ways to do this I'm open to those as well.
Regards
Upvotes: 0
Views: 4765
Reputation: 707158
You need your string in quotes like this:
location.href = "/foo/?q=1&a=2";
Javascript was probably interpreting /foo/
as a regular expression and then trying to make sense of the other characters after it as options on the regex.
Upvotes: 3