Search code examples
ajaxweb2py

Ajax call in web2py with a # passed in request.vars chops the later part


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.


Solution

  • 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.