Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6765899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:46:01+00:00 2026-05-26T14:46:01+00:00

I have a stand-alone svg file that displays without problems. It includes some inline

  • 0

I have a stand-alone svg file that displays without problems. It includes some inline script, and references to 2 other scripts. The inline script calls an initialisation function in one of the other scripts, and this works on all the big browsers:

<svg ...>
<script type="application/ecmascript"><![CDATA[
...
do_init_in_foo1();
...
]]></script>
<script type="application/ecmascript" xlink:href="foo1.js"></script>
<script type="application/ecmascript" xlink:href="foo2.js"></script>
</svg>

Ok, here’s the problem: when I instead load this script dynamically via Ajax, ‘do_init_in_foo1’ is no longer visible. It still works in Opera if the ‘foo1.js’ reference appears above the init call, and works in older versions of F/F, but otherwise doesn’t work at all in the other browsers, irrespective of how I arrange the 3 script sections. The error message I get is ReferenceError: do_init_in_foo1 is not defined.

What is it about dynamic Ajax loading that changes the visibility? Is there some way around this?

One option is to move this line:

<script type="application/ecmascript" xlink:href="foo1.js"></script>

into the parent document, since it doesn’t change on different Ajax calls. However, if I do this, the browser complains about the moved script tag (Namespace prefix xlink for href on script is not defined). I think I would need to wrap the script tag in an svg tag to fix this, with an xmlns:xlink attribute, but this would then give me two top-level svgs, which would be (I think) a problem.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:46:01+00:00Added an answer on May 26, 2026 at 2:46 pm

    You can’t rely on dynamically loaded javascript code, because you don’t know whether it’s loaded or not at the point you try to access it in your code. The best approach here is to call some function in your loaded script. For example, if you load foo1.js via AJAX call, you may add the following function at the end of this file:

    function foo1Loaded(){
     do_init_in_foo1();
     //and here do whatever you need to do else with variables/functions from loaded file
    }
    foo1Loaded();
    

    If you want to know when all the external scripts are loaded via AJAX calls, you may count them once they loaded (via callback functions, similar to described above).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my idea: Have a tiny, stand-alone JavaScript file that will start up after
I have python script that works fine but only when run as stand-alone, while
I have a problem that I feel is best implimented in a stand alone
I have a stand-alone, Swing application that uses Hibernate for its persistence layer. I
I have noticed, that as of V7.x, there are two stand-alone distributions of Jetty.
I have some scripts written with d3.js that generate SVG charts. I'd like to
We have developed a stand-alone script on the same server as our Joomla 1.5
I have an svg file which is almost entirely made up of a script.
Is there a good way to write F# scripts that execute stand-alone without compiling?
At school we have been using a bootstrap program to run stand-alone programs without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.