在 Javascript 中对部分 url 进行编码
嘿, 我知道这很容易,但由于某种原因,我就是想不出解决方案。我正在使用 facebook javascript sdk。我尝试实现分页功能。基本上,我可以使用response.paging.next提取下一个对象的url,这给了我:
/me/home?access_token=blabla&limit=25&until=2011-01-17T00:30:42+0000
但是,我需要调用它的是:
/me/home?access_token=encodedblabla&limit=25&until=2011-01-17T00%3A38%3A15%2B0000
它也可以在罕见的json字符串中找到。
看来,当我调用response.paging.next时,解析器会自动解码url,而我似乎无法找到一种方法来获取编码后的url。每当我尝试对整个网址进行编码时,显然它不再是有效的网址,所以我想我需要对每个参数进行编码?
Hey,
i know it is easy, but for some reason, i just cant come up with the solution. i am using the facebook javascript sdk. I try to implement the paging feature. bascically, i can extract the url for the next objects with response.paging.next which gives me:
/me/home?access_token=blabla&limit=25&until=2011-01-17T00:30:42+0000
However, what i need to call this is:
/me/home?access_token=encodedblabla&limit=25&until=2011-01-17T00%3A38%3A15%2B0000
which can also be found in the rare json string.
it seems, when i call response.paging.next, the parser automatically decodes the url and i just cant seem to find a way to get the encoded url back. whenever i try to encode the whole url, obviously it is not an valid url anymore, so i guess i need to encode each parameter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Javascript 的
escape
方法会做你想要的事情吗?Would Javascript's
escape
method do what you want?我确信有一种更简单的方法,但在那之前我使用了:
i am sure there is an easier way, but until then i used: