的Xmlhtt prequest prevent重定向 [英] Prevent redirection of Xmlhttprequest

查看:157
本文介绍了的Xmlhtt prequest prevent重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能prevent从以下的重定向发送时XMLHtt prequest-S(即获得重定向状态code背部和处理它自己)?

浏览器
解决方案

不按照<一个href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send%28%29-method">the为XMLHtt prequest对象 W3C标准(强调):

  

如果响应是一个HTTP重定向:

     
    

如果通过Location头所传达的URL的起源是相同的起源     与XMLHtt prequest起源和     重定向不违反无限     环precautions,透明     按照重定向,同时观察     同源请求事件的规则。

  

他们考虑它在将来的版本:

  

该规范不包括   下列功能这是被   考虑未来版本   这说明:

     
      
  • 属性禁用以下的重定向;
  •   

最新规范不再提到了这一点。

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)?

解决方案

Not according to the W3C standard for the XMLHttpRequest object (emphasis added):

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.

They were considering it for a future release:

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

  • Property to disable following redirects;

but the latest specification no longer mentions this.

这篇关于的Xmlhtt prequest prevent重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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