0
var x = "www.something.com#something"

ajax("default?q="+x,"","");

Here, in the controller, the value obtained in request.vars is only www.something.com instead of www.something.com#something

Looks like anything written after # is not taken into consideration.

Although it works fine when passed a "name" but not sure why this won't work in the above scenario. Please help.

R Day
  • 962
  • 9
  • 25
  • `#` is client-side only (in principle). It's one of the reserved characters for URLs. See point 2 in [this blog post](https://blog.httpwatch.com/2011/03/01/6-things-you-should-know-about-fragment-urls/) and [wikipedia](https://en.wikipedia.org/wiki/Fragment_identifier). – Kenney Dec 16 '15 at 19:27
  • very nice! Thanks a lot. – user5688150 Dec 16 '15 at 20:28

1 Answers1

0

The # symbol in a URL represents a fragment, a fragment is not likely to be included in request.vars so you will need to encode the value q with something like encodeURIComponent before sending it in a request.

R Day
  • 962
  • 9
  • 25
  • 1
    thanks a lot for the answer, but then should I use encodeURIComponent() if i am preparing the request from front end ( as front end won't be able to call urllib.urlencode once a page load? – user5688150 Dec 16 '15 at 20:25