0

我创建了一个 office-js 插件,它打开了一个作为 Azure 应用服务托管的 dialog-api。dialog-api 向 asp.net Web api(使用 Azure AD 保护)发送 AJAX 调用。

调用 web api 时出现错误:

在此处输入图像描述

Ajax 调用的代码:

 $.ajax({
                    url:'.../api/DocFile4/GetVersions',
                    type: 'GET',
                    crossDomain: true,
                    async: false,
                    contentType: 'application/json;charset=utf-8',
                }).done(function (data) {
                    console.log("success");
                }).fail(function (status) {
                    console.log('Error', 'Could not communicate with the server.');
                });

Office-js 插件和 dialog-api 托管在同一个应用服务上,而 asp.net Web api 托管在单独的应用服务上,两者都是应用服务在同一个资源组中。

4

1 回答 1

0

问题是由于您的浏览器中的 CORS 策略保护您的请求。它不允许来自外部网站的参数。您需要将您的网站设置为允许文章中提到的请求。

于 2020-06-09T19:42:29.273 回答