admin管理员组文章数量:1290935
I am using javascript (using jquery) to pass a # symbol as a GET parameter via AJAX call.
The problem right now is that the # symbol is breaking up my querystring.
Any help appreciated. Thanks!
I am using javascript (using jquery) to pass a # symbol as a GET parameter via AJAX call.
The problem right now is that the # symbol is breaking up my querystring.
Any help appreciated. Thanks!
Share Improve this question asked Jan 21, 2010 at 18:21 resopollutionresopollution 20.4k10 gold badges42 silver badges49 bronze badges4 Answers
Reset to default 7You need to replace it with %23
in the string. However, instead of doing this directly you should use Javascript function encodeURIComponent
to encode characters in the URL.
Alternatively, if you are using jQuery.ajax you can automatically encode parameters by passing them in via the data
option.
If you are passing the data parameter to jQuery.ajax, jQuery does the encoding for you. You shouldn't be trying to build the URL yourself.
$.ajax({ url : "http://myserver./mypage.aspx",
data : {'key1' : 'value#', 'key2' : 'value&&'}
...
});
Use encodeURIComponent().
You will have to encode the url using escape, encodeURIComponent function, etc to pass that character. This will turn the characters into their % counter-partts. For example, # will be %23
本文标签: javascriptHow do I pass thesymbol as part of a GET querystring in the URLStack Overflow
版权声明:本文标题:javascript - How do I pass the # symbol as part of a GET querystring in the URL? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741508167a2382444.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论