MicrosoftAjax.js is not loaded successfully inside Office application

蓝咒 提交于 2019-12-24 00:53:55

问题


I was using the CDN release of office-js, but had to change to a local version. After this change, it seems Office.initialize is not being run, which means the add-in doesn't work correctly. On the console, I see the following error:

SCRIPT5022: MicrosoftAjax.js is not loaded successfully.
office.js (18,26767)

The only references to MicrosoftAjax.js that I can find are ASP.NET related, but my project is Typescript/React. Here's how office.js is being loaded in the html:

<!doctype html>
<html lang="en" data-framework="typescript">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>wincross-formatter</title>
</head>

<body class="ms-font-m">
  <script src="/assets/office.js"></script>
  <div id="container"></div>
</body>

</html>

How can I fix this error?

EDIT:

As per this page, I added the following line just above the office-js script:

<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>

Adding it after the office-js script gives me this error instead of the previous one, and Office.initialize still isn't being called:

SCRIPT5022: Neither the locale, en-us, provided by the host app nor the fallback locale en-us are supported.

FINAL EDIT: That was completely my fault. I didn't copy the contents of office-js/dist recursively.

来源:https://stackoverflow.com/questions/55631948/microsoftajax-js-is-not-loaded-successfully-inside-office-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!