How do you run a javascript outside of the localhost directory with requirejs?

236 views Asked by At

I am working with a multi directory program that relies on requirejs, and I'm new to this structure and to javascript in general.

I have a html file that is in a localhost and I need to get it to access a variable that is stored in a javascript file outside of that localhost. I've tried creating a global variable, but the javascript file storing the variable isn't run, so the value is never set and the global variable is null. The file structure is:

  • lib
    • direc
      • config
        • script1.js
      • src
        • public
          • script2.js
          • index.html

I need to run script1 from index and when I use the format below I get a 404 error.

<script src ="../../config/script1.js"></script>

The variable I need to pass is a string that was parsed by script1.js from a kaml file, although I'm not sure if it's parsed correctly since this script doesn't seem to be running since it isn't called from the html. Also, the localhost seems to be centered at the public folder and the 404 error indicates that it is looking for script1 at the url "localhost/config/script1.js". Like I said I'm new to javascript and to node.js, but I've looked for this answer and have yet to find something that works with my program.

0

There are 0 answers