1

I'd like to create a google-docs add-on that sends an ajax call to a webhook.

I've tried the below, but I get the following error

Error

ReferenceError: "$" is not defined. (line 5, file "")

Code

function myFunction() {
    var arr = 'data'

    $.ajax({
        url: 'webhook_url',
        type: 'POST',
        data: arr,
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        async: false,
        success: function () {
            alert('Success');
        }
    });
}

If ajax can't be used here is there any other way to make a request to a server-side resource

Ash
  • 2,108
  • 2
  • 17
  • 22
Chris
  • 5,444
  • 16
  • 63
  • 119

1 Answers1

0

This is an OLD question, so I don't know if you still have the issue, but, from the error you're getting Jquery is either not added, or not available.

You could try doing it with vanilla js, see this link for a walkthrough: https://www.sitepoint.com/guide-vanilla-ajax-without-jquery/

TraaidMark
  • 63
  • 8