javascript - 防止重定向 Xmlhttprequest

标签 javascript ajax xmlhttprequest

是否可以在发送 XMLHttpRequest-s 时阻止浏览器跟随重定向(即获取重定向状态代码并自行处理)?

最佳答案

不符合 the W3C standard for the XMLHttpRequest object (强调):

If the response is an HTTP redirect:

If the origin of the URL conveyed by the Location header is same origin with the XMLHttpRequest origin and the redirect does not violate infinite loop precautions, transparently follow the redirect while observing the same-origin request event rules.

它们是 considering它用于将来的版本:

This specification does not include the following features which are being considered for a future version of this specification:

  • Property to disable following redirects;

但是latest规范不再提及这一点。

关于javascript - 防止重定向 Xmlhttprequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/228225/

相关文章:

javascript - 在 XMLHttpRequest 中获取 SENT header

javascript - 如果我用 fadeToggle 替换 fadeIn/fadeOut 为什么它不起作用

javascript - 如何将css文件添加到pdf文档中?

javascript - 提供一个对话框以在 Web 应用程序上使用浏览器固有的全屏

mysql - NameError - 未定义的局部变量 - 将数组从 ruby​​ 文件解析为 haml 文件

javascript - 追加并处理从服务器返回的JS代码

javascript - processQueue() 在多个上传中不起作用

javascript - PHP/AJAX 解析错误

php - XMLHttpRequest 的问题

javascript - Cors 不适用于 XMLhttprequest Node/ express