Hi,
I have a Stash plug-in that calls several REST services to collect various data for showing in a ClientWebPanel in Stash. Unfortunately, these calls can sometimes take a significant amount of time which results in the whole page (i.e., pull request page) not being loaded until the context provider function finishes:
function doSomeRestCallsToCollectContextForClientWebPanel(context) { var result = null; $.ajax(..., async: false, success: function (json) { result = // ... }); return result; } <client-context-provider>doSomeRestCallsToCollectContextForClientWebPanel</client-context-provider>
Am I right that there is no way to provide the context for client web panel's asynchronous so that the page can be rendered in the meantime?
Thanks,
Michael
Community moderators have prevented the ability to post new answers.
Unfortunately, there is no built-in way to provide async data to your panel. I've created a JIRA for adding support for this: https://jira.atlassian.com/browse/STASH-7330
The best workaround in the meantime is not to use sync AJAX requests, but instead to render a "loading" template initially, then replace it with a new template manually when your data is available. See https://answers.atlassian.com/questions/14812632 for the same answer using other words, if that helps. :/
Cheers,
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By default, the ajax function is set to asynchronous.
I can suggest 2 things. You can try setting it explicitly in the ajax function, add the params "async : true", or use another javascript/jquery (like .get https://api.jquery.com/jquery.get/).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well yes, certainly. But the problem here is that I need to return the results which are then passed to my Soy template where it is rendered. And I cannot return a promise or something like that here. I have to yield the results from this function, hence I have to wait (synchronously). Or am I wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.