XMLHttpRequest:网络错误 0x80070005,在 Microsoft Edge(但不是 IE)上拒绝访问

2023-04-18前端开发问题
19

本文介绍了XMLHttpRequest:网络错误 0x80070005,在 Microsoft Edge(但不是 IE)上拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个非常简单的 ajax 请求(见下文).服务器正在使用 CORS,并且在 IE 10+、Chrome、Firefox 和 Opera 中运行良好.但是,在 Microsoft Edge 上,它会失败并显示

I have a very simple ajax request (see below). The server is using CORS and works fine in IE 10+, Chrome, Firefox and Opera. On Microsoft Edge however, it fails with

XMLHttpRequest:网络错误 0x80070005,访问被拒绝.

XMLHttpRequest: Network Error 0x80070005, Access is denied.

我研究了这里,这里,这里和这里,但找不到答案作品.那些人在使用 IE 时遇到了问题,但是添加 contentType(此获取不需要)和 crossDomain 可以正常工作.

I have researched the posts here, here, here and here, but cannot find an answer that works. Those people have had issues with IE, but adding the contentType (not required for this get) and crossDomain has it working fine.

CanIUse 似乎表明 CORS 在 Edge 中可用.该请求在 IE9 关闭时也会失败,但 CanIUse 仅声明对 CORS 的部分支持,所以这是可以理解的.

CanIUse seems to state that CORS is usable in Edge. The request also fails on IE9 down, but CanIUse states only partial support for CORS, so that's understandable.

请问有什么办法可以解决这个问题吗?

Any ideas how I can fix this please?

代码:

$.ajax({
      crossDomain: true,
      url: "http://localhost:2023/api/DoAction/test",
      success: function (a) {
        var res = JSON.parse(a);
        alert(res.content);
      },
      error: function (a, e, r) {
        alert(a.responseText);
      }
    });

更新

添加更多信息以防提供任何线索 - ajax 请求来自 Azure 并发布到使用 OWIN 自托管创建的 localhost 网站.这是不寻常的,但软件(只能在本地使用)从云服务获取数据是必需的.如前所述,它适用于所有其他浏览器,Edge 是唯一的问题.

To add further information in case it provides any clues - the ajax request is coming from Azure and posting to a localhost website created using OWIN self hosting. This is unusual, but required for the software (which can only be used locally) to get data from a cloud service. As stated, it works fine for all other browsers, Edge is the only problem.

推荐答案

对于使用 Microsoft Edge 的开发人员来说,这个问题应该不再存在.如果您在 localhost 测试中遇到问题,请导航到 about:flags,并确保选中 Allow localhost loopback.

This problem should no longer exist for developers using Microsoft Edge. If you experience issues with localhost testing, navigate to about:flags, and make sure Allow localhost loopback is checked.

Microsoft Edge当前不支持(开箱即用)本地主机测试.但是,您可以按照此处提供的指南启用它:http://dev.modern.ie/platform/faq/how-can-i-debug-localhost/.

Microsoft Edge does not currently support (out of the box) localhost testing. You can however enable it by following the guidance provided here: http://dev.modern.ie/platform/faq/how-can-i-debug-localhost/.

我们正在努力在未来的版本中解决此问题.

We're working on resolving this in a future release.

这篇关于XMLHttpRequest:网络错误 0x80070005,在 Microsoft Edge(但不是 IE)上拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

ajax请求获取json数据并处理的实例代码
ajax请求获取json数据并处理的实例代码 $.ajax({ type: 'GET', url: 'https://localhost:44369/UserInfo/EditUserJson',//请求数据 data: json,//传递数据 //dataType:'json/text',//预计服务器返回的类型 timeout: 3000,//请求超时的时间 //回调函数传参 suc...
2024-11-22 前端开发问题
215

js删除数组中指定元素的5种方法
在JavaScript中,我们有多种方法可以删除数组中的指定元素。以下给出了5种常见的方法并提供了相应的代码示例: 1.使用splice()方法: let array = [0, 1, 2, 3, 4, 5];let index = array.indexOf(2);if (index -1) { array.splice(index, 1);}// array = [0,...
2024-11-22 前端开发问题
182

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

JavaScript小数运算出现多位的解决办法
在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会...
2024-10-18 前端开发问题
301

JavaScript(js)文件字符串中丢失"\"斜线的解决方法
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转...
2024-10-17 前端开发问题
437

layui中table列表 增加属性 edit="date",不生效怎么办?
如果你想在 layui 的 table 列表中增加 edit=date 属性但不生效,可能是以下问题导致的: 1. 缺少日期组件的初始化 如果想在表格中使用日期组件,需要在页面中引入 layui 的日期组件,并初始化: script type="text/javascript" src="/layui/layui.js"/scrip...
2024-06-11 前端开发问题
455