阿贾克斯重定向处理重定向、阿贾克斯

2023-09-10 19:12:58 作者:丢了剧本的配角

我碰上一个情况下,我从未有过处理。我有谁需要做一个Ajax请求URL的客户。对于内部原因,URL重定向到另一个网址的状态code需要访问。正是这种多请求的情况通过Ajax请求处理的原生?

I bumped into a situation I've never had to address before. I have a customer who needs to make an ajax request to a URL. For internal reasons, that URL redirects to another URL whose status code needs to be accessed. Is this kind of multi-request scenario handled natively by Ajax requests?

一个快速测试使用jQuery似乎处理302,执行重定向并返回目标网页的内容(我只需要状态code生产,但内容是证明正确的页面被访问),但我找不到任何迹象表明我可以期待这个工作普遍。我不知道如果有,库中的客户端将使用什么。此外,其他客户端很可能在将来使用相同的URL,并需要将其处理方式相同。

A quick test using jQuery seems to handle the 302, do the redirection and return the content of the targeted page (I'll only need the status code in production, but the content is what "proves" the correct page is being accessed), but I can't find any indication that I can expect this to work universally. I don't know what, if any, library the client will use. Moreover, other clients are likely to use this same URL in the future and it needs to be handled the same way.

感谢。

推荐答案

您的可以的期望这普遍的工作,因为它不是jQuery的做处理。这是指定的所有的库使用AJAX调用底层 XmlHt prequest 浏览器对象的行为。

You can expect this to work universally, since it's not jQuery doing the handling. This is specified behavior of the underlying XmlHtpRequest browser object that all libraries use for AJAX calls.

您可以在这里找到由W3C :

如果在的

 
精彩推荐
图片推荐