铬HEAD XMLHtt prequest [英] HEAD XMLHttpRequest on Chromium

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

问题描述

我试图让与XMLHtt prequest中铬的HEAD响应以检索一个COM pressed URL的位置URL,但它失败:

  VAR阿贾克斯=新XMLHtt prequest();
ajax.onreadystatechange =功能(){如果(ajax.readyState == 4)警报(ajax.getResponseHeader(位置))};
ajax.open(HEAD,http://bit.ly/4Agih5,假);
ajax.send();

//不肯不安全头位置
//错误:NETWORK_ERR:XMLHtt prequest异常101
 

解决方案

由于穆罕默德表示,你必须创建您的,因为这是一个跨域请求承载您的网页同样的网站代理服务。

这应该没有在所有浏览器,除非你已经明确允许在浏览器跨域请求。如果通过 W3C规范的访问控制 - 允许 - 产地那么你的code会的工作。

I'm trying to get the HEAD response with an XMLHttpRequest in Chromium to retrive the location URL of a compressed url, but it fails:

var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function() { if (ajax.readyState == 4) alert(ajax.getResponseHeader("Location")) };
ajax.open('HEAD', "http://bit.ly/4Agih5", false);
ajax.send();

// Refused to get unsafe header "Location"
// Error: NETWORK_ERR: XMLHttpRequest Exception 101

解决方案

As Mohamed indicated, you will have to create a proxy service on the same site that you are hosting your page on as this is a cross domain request.

This should be failing in all browsers, unless you have explicitly allowed cross domain requests in your Browser. If bit.ly supported cross domain requests via the W3C spec for Access-Control-Allow-Origin then your code would work.

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

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