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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:07:01+00:00 2026-05-14T22:07:01+00:00

Currently I am working on a legacy web page that uses a ton of

  • 0

Currently I am working on a legacy web page that uses a ton of JavaScript, jQuery, Microsoft client JavaScript, and other libraries. The bottom line – I cannot rewrite the entire page from scratch as the business cannot justify it. So… it is what it is. Anyway, I need to pollute (I really tried not too) the global namespace with a variable. There are the three options I was thinking about –

  1. Just store/retrieve it using a normal JavaScript declaration – var x = 0;

  2. Use jQuery to store/retrieve the value in a DOM tag – $("body").data("x", 0);

  3. Use a hidden form field, and set/retrieve the value with jQuery – $("whatever").data("x", 0);

Is there a better way? I looked at the existing pile of code, and I do not believe the variable can be scoped in a function.

  • 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-14T22:07:02+00:00Added an answer on May 14, 2026 at 10:07 pm

    You can create a namespace inside the jQuery object, like so:

    $.mynamespace = { 
        myVar : "something", 
        myVar2 : "somethingElse" 
    }; 
    

    or:

    $.mynamespace = {};
    $.mynamespace.myVar = "something";
    $.mynamespace.myVar2 = "somethingElse";
    

    Bear in mind, any plugin method named ‘mynamespace’ will be overwritten so be sure to use a sensible name.

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

Sidebar

Related Questions

I am working on a legacy jsp web application that uses JDBC and inline
Im currently working on a game that uses multi touch to apply zoom to
I'm currently working on a legacy ASP.NET 2.0 web application using a MySQL 5
I am currently doing some work for a company that runs a legacy web
Background: I'm working on a legacy code of a web application and I'm currently
I am working on a legacy application that contains references to two .asmx web
i am working on a legacy enterprise database that uses multiple columns to retrieve
We are working with a legacy database that uses SQL server uniqueidentifier columns for
I am currently working on a (legacy) programme that has been written in C++
I'm currently working on a legacy app (win32, Visual C++ 2005) that allocates memory

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.