带有磅(数字)符号的URL上的jQuery Ajax调用 [英] jQuery Ajax Call on URL with Pound (Number) Sign

查看:151
本文介绍了带有磅(数字)符号的URL上的jQuery Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对其中带有#号的URL进行jQuery Ajax调用.例如:

I'm trying to do a jQuery Ajax call to a URL that has a # sign in it. For example:

https://www.foo.com/myapp/app/#ptc1/tcomp/infoPage?oid=VR:wt.doc.WTDocument:1272991906

但是,Ajax调用所调用的URL被截断为" https://www .foo.com/myapp/app/".之所以出现这种情况,是因为jQuery将#号视为锚定符,并将其后的所有内容从URL中剥离.

However, the URL being called by the Ajax call is being truncated to just "https://www.foo.com/myapp/app/". It appears as this is because jQuery treats the # sign as an anchor designator and strips everything after it off of the URL.

因此,我尝试同时使用encodeUriComponent并进行直接替换以将#符号转换为%23的十六进制等效值.但是,如果我这样做并调用了URL,那么我会得到一个404.

So, I tried using both encodeUriComponent and doing a straight up replace to convert the # sign to it's hex equivilent of %23. However, if I do that and call the URL, I then get a 404.

是否可以解决此问题?还是服务器上的错误,是由于不了解%23与#相同?

Is there any way around this or is the fault on the server for not understanding that %23 is the same as #?

也许我应该重新表述这个问题,因为它没有得到任何答案.

Maybe I should re-phrase this question, as it is not getting any answers.

是否有任何方法可以告诉JQuery在对Ajax调用的URL中使用#号后不要剥离所有内容?

Is there any way to tell JQuery to NOT strip off everything after the # sign in a URL for an Ajax call?

推荐答案

这似乎是因为jQuery将#号视为锚定符,然后将其后的所有内容从URL中剥离.

It appears as this is because jQuery treats the # sign as an anchor designator and strips everything after it off of the URL.

那不是jQuery,那是浏览器.

That isn't jQuery, that's the browser.

片段标识符永远不会作为URL的一部分发送到服务器.

Fragment identifiers are never sent to the server as part of the URL.

您提供的网址会引发404错误(可能是您想提供示例网址,请使用example.comfoo.com是真实网站!),但我认为网页会根据#在网页中的客户端JavaScript而不是服务器中放置#之后发生的变化而改变.

The URL you've provided throws a 404 error (presumably you were trying to provide an example URL, please use example.com for that, foo.com is a real site!) but I would assume that anything shown on the page which changes based on what comes after the # is put there by client side JavaScript in the page, and not by the server.

要复制它,您需要对他们的JS进行反向工程,并以自己的代码重现它对页面所做的更改.

In order to replicate it, you would need to reverse engineer their JS and reproduce the changes it makes to the page in your own code.

这篇关于带有磅(数字)符号的URL上的jQuery Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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