防止重定向 Xmlhttprequest [英] Prevent redirection of Xmlhttprequest

查看:36
本文介绍了防止重定向 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 标准(强调):

如果响应是 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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