make use of "ad_unless_script_abort"
Got a suggestion or an issue? Discuss it on the Atlassian Community or visit Atlassian Support for other options.