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 8422861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:34:27+00:00 2026-06-10T03:34:27+00:00

How do I properly communicate data betweens two scripts. In this particular case I

  • 0

How do I properly communicate data betweens two scripts.

In this particular case I have an element in one script, but I want to append it in another script.

The simplest way I could do this is by using the global window object as go-between.

But globals are not best practice.

What is the correct way to pass this element to another script?

Both script are encapsulated in the module pattern.

Script 0 Create Element Point

var element = document.createElement( "div" );
element.innerHTML = response_text;

Script 1 Append Element Point

Vi.sta = {

    // implemented in the boot loader - shared global space - appended child already - you don't have to append until now.
    // Static data has already been composed. 
    // Pull off window and append or best practice

};

Both are encapsulated in the module pattern

(function(){ 
    // the code here 
})()
  • 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-06-10T03:34:28+00:00Added an answer on June 10, 2026 at 3:34 am

    All JS scripts are run in the global scope. When the files are downloaded to the client, they are parsed in the global scope.

    So if you’ve got

    // File_1.js
    var myObj = { colour : "blue" };
    

    There’s nothing stopping you from doing this:

    // File_2.js
    var otherObj = { colour : myObj.colour };
    

    As long as File_1.js is loaded before File_2.js

    If you are namespacing, ie: MYNAMESPACE = {}; and each file extends your namespace through modules (rather than “module pattern” referring to returning interfaces from immediately-invoking functions), then check for the module’s existence.

    If you ARE writing modules for a namespaced app, and you DO need access to variables from one module to another, then you should be providing an interface for that.

    If you are SANDBOXING modules, then you need to provide them all a proxy similar to a service-locator or a "registry", or develop a messaging-system based on a mediator-pattern.

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

Sidebar

Related Questions

This code compiled properly on Visual Studio 2010 on Windows, but I'm getting this
I have program where client peers communicate with each other via TCP-IP. When one
I have 5 processes p1,p2,...,p5 where I want to write some data to stdin
I have a .NET 4.0 project with two modules that will communicate via WCF
I'm working on a project where I have to take data from one source
I can't link properly to glew. I have done: #define GLEW_STATIC #include glew/glew.h #pragma
Possible Duplicate: How to properly clean up Excel interop objects in C# I have
I'm not sure exactly how to describe this question, but here goes. I've got
I have a form that I want to be used to add entries. Once
I'm using a named pipe to communicate between a PHP script and a C++

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.