Word Office JS插件-GET请求-对象不支持属性或方法“应用”

时间:2019-11-24 11:25:06

标签: javascript ajax ms-word office-js word-addins

我正在尝试使用ajax请求通过Word Office JavaScript插件从Web API获取一些数据。但是,拨打电话时出现以下错误:

0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“应用”

这是我的代码:

Office.onReady(function () {
        // Office is ready
        $(document).ready(function () {
            // The document is ready
            // Use this to check whether the API is supported in the Word client.
            if (Office.context.requirements.isSetSupported('WordApi', '1.1')) {

                $('#rooms').click(Word.run(function (context) {
                    $.ajax({
                        url: "http://localhost/soundtestingsoftware/public/api/projects/27/rooms",
                        type: "GET",
                        success: function (result) {
                            var doc = context.document.getSelection();
                            doc.insertText(JSON.stringify(result), Word.InsertLocation.start);
                            return context.sync();
                        },
                        error: function (err) {
                            console.log(err);
                        }
                    });
                }));

                $('#supportedVersion').html('This code is using Word 2016 or later.');
            }
            else {
                // Just letting you know that this code will not work with your version of Word.
                $('#supportedVersion').html('This code requires Word 2016 or later.');
            }
        });
    });

我已将AppDomain添加到清单文件中。有人可以告诉我为什么会发生此错误吗?谢谢

0 个答案:

没有答案