我想从.NET应用程序调用API,但不幸的是我收到错误:
“Script7002:XMLhttpREQUEST:网络错误0x80070005,访问被拒绝。”
如果我使用“Advanced Rest Client(ARC)”Chrome扩展程序测试API,那么我会得到正确的响应。我该如何解决这个问题?
下面我给出了我用来从.NET应用程序调用API的代码。
<script type = "text/javascript">
function ShowCurrentTime() {
alert("start");
$.ajax({
url: "https://XXXXXXXXXXXX/api/xx/xxxxxx",
dataType: "application/json",
type: "POST",
data: {
"Username": "xxxxxx",
"Password": "xxxxxxx",
"Code": "xxx"
},
success: function (r) { alert("success"); }
});
alert("finished");
}
</script>
答案 0 :(得分:-1)
在Internet Explorer中尝试此选项:
安全区域( Internet选项→安全)。启用设置其他→跨域访问数据源。