如何在URL中将#符号作为GET查询字符串的一部分传递? [英] How do I pass the # symbol as part of a GET querystring in the URL?

查看:86
本文介绍了如何在URL中将#符号作为GET查询字符串的一部分传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用javascript(使用jquery)通过AJAX调用将#符号作为GET参数传递.

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!

推荐答案

您需要在字符串中将其替换为%23.但是,与其直接执行此操作,不如使用Javascript函数encodeURIComponent在URL中编码字符.

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

或者,如果您使用的是jQuery.ajax,则可以通过data选项将其传递来自动编码参数.

Alternatively, if you are using jQuery.ajax you can automatically encode parameters by passing them in via the data option.

这篇关于如何在URL中将#符号作为GET查询字符串的一部分传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆