铬HEAD XMLHtt prequestHEAD、XMLHtt、prequest

2023-09-10 20:14:05 作者:每一种创伤都是一种成熟

我试图让与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会的工作。

httos双向认证配置 SoapUI入门之附件上传和配置Https请求

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.

 
精彩推荐
图片推荐