Word Office JS Addin - GET Request - Object doesn't support property or method 'apply'

0

I'm trying to get some data from a Web API through a Word Office JavaScript addin using an ajax request. However, I am getting the following error when I make the call:

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'apply'

Here is my code:

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.');
            }
        });
    });

I've added my AppDomain into the manifest file. Could someone tell me why this error is happening please? Thanks

javascript
ajax
ms-word
office-js
word-addins
asked on Stack Overflow Nov 24, 2019 by Curtis Thompson • edited Dec 8, 2019 by Cindy Meister

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0