In an Atlassian connect plugin, we've this code

$(document).ready(function() {
    AP.require('request', function(request) {

which works fine, but sometimes and randomly we receive the error message in the object

AP is not defined

And this is not related to a specific browser or OS

Any idea of why this happens?

Any suggestion on what to investigate?

Thanks

 

 

That's the head section of my web panel

<html lang="en">
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script src="//aui-cdn.atlassian.com/aui-adg/6.0.6/js/aui.min.js"></script>
        <link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/6.0.6/css/aui.min.css" media="all">
        <link rel="stylesheet" href="mycustom.css">
        <script src="mycustom.js"></script>
    </head>

and that's the last part of the body

<!-- Stop the loading addon message -->
    <script id="connect-loader" data-options="sizeToParent:true;">
        (function() {
            var getUrlParam = function(param) {
                var codedParam = (new RegExp(param + '=([^&]*)')).exec(window.location.search)[1];
                return decodeURIComponent(codedParam);
            };

            var baseUrl = getUrlParam('xdm_e') + getUrlParam('cp');
            var options = document.getElementById('connect-loader').getAttribute('data-options');
            var script = document.createElement("script");
            script.src = baseUrl + '/atlassian-connect/all.js';

            if (options) {
                script.setAttribute('data-options', options);
            }

            document.getElementsByTagName("head")[0].appendChild(script);
        })();
    </script>
</body>

as described in the Atlassian dev documentation

2 answers

0 votes
Volodymyr Krupach Community Champion Mar 08, 2017

AP is defined in "integration bridge" all.js loaded from your host JIRA:

https://YOUR-ATLASSIAN-DOMAIN/atlassian-connect/all.js

I guess that all.js is not loaded (which should not happen) or maybe your load your custom JS file before all.js.

all.js is loaded before my custom JS because the code works fine, 

and my JS is loaded at last in my web panel

but it seems that sometime (and I don't know when and why) 

AP is not available (i.e. all.js is not loaded?)

Volodymyr Krupach Community Champion Mar 08, 2017

Make sure you do no have async attribute in script tags.

I am running into this exact same issue with loading all.js from our JIRA instance. The script loader is absolutely doing the right thing, we've used it forever for our Confluence add-on and I've verified that it's present and loaded in the DOM. It's all.js that has an issue when it tries to execute.

I'm getting an Uncaught TypeError: Object.defineProperty called on a non-object, and AP fails to be created or made available to our add-in

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,036 views 6 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot