Get request part after hash sign

后端 未结 2 1685
隐瞒了意图╮
隐瞒了意图╮ 2021-01-11 16:19

My web-site has AJAX-powered search, that uses deep-linking. When user follows a link …

http://example.com/articles#/?tags=Mac%20OS,review

相关标签:
2条回答
  • 2021-01-11 16:32

    @NickFitz is correct, but if you must send whatever comes after the # hash/pound symbol, you can use the URL encoded characters that represent # which is %23.

    So %23 and whatever that comes after %23 will be sent to the server. If you are using modern web server, they will automatically recognize that %23 is #. In Ruby on Rails, Rack does this for you.

    0 讨论(0)
  • 2021-01-11 16:36

    The part of a URL after the hash is not sent to the server, so you can't process it there. You can extract that part of the URL in the client-side code that creates your Ajax request and send it as a parameter.

    0 讨论(0)
提交回复
热议问题