Prevent redirection of Xmlhttprequest(防止 Xmlhttprequest 的重定向)
问题描述
是否可以在发送 XMLHttpRequest-s 时阻止浏览器跟随重定向(即取回重定向状态码并自己处理)?
Is it possible to prevent the browser from following redirects when sending XMLHttpRequest-s (i.e. to get the redirect status code back and handle it myself)?
推荐答案
不按照XMLHttpRequest 对象的 W3C 标准(已添加重点):
Not according to the W3C standard for the XMLHttpRequest object (emphasis added):
如果响应是 HTTP 重定向:
If the response is an HTTP redirect:
如果 Location 标头传达的 URL 的来源是同一个来源与 XMLHttpRequest 来源和重定向不违反无限循环预防措施,透明在观察的同时遵循重定向同源请求事件规则.
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.
他们考虑在未来发布:
本规范不包括以下功能正在考虑用于未来版本本规范:
This specification does not include the following features which are being considered for a future version of this specification:
- 禁用以下重定向的属性;
但 最新 规范不再提及这一点.
but the latest specification no longer mentions this.
这篇关于防止 Xmlhttprequest 的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:防止 Xmlhttprequest 的重定向


基础教程推荐
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01