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

  • Home
  • SEARCH
  • 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 905411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:12:50+00:00 2026-05-15T16:12:50+00:00

This should be fairly simple; i’m pretty sure I’ve just not understood it. FYI,

  • 0

This should be fairly simple; i’m pretty sure I’ve just not understood it.

FYI, the website is using jQuery to run ajax .load() on content.

On my main parent page, in the header I have my nav .load() jQuery code:-

<script type="text/javascript" charset="utf-8">

    $(document).ready(function(){

        $('a.nav').click(function() {
            page = $(this).attr('page');
            projID= $(this).attr('projID');

            if($("#mainRight").is(":visible")) { $('#mainRight').hide(200); }

            switch(page) {

            case 'projSettings': $("#mainRight").load("content.php?load=" + page, { projID: projID}); break;
            case 'projMetrics': $("#mainRight").load("content.php?load=" + page, { projID: '5000227' }); break;
            case 'projTags': $("#mainRight").load("content.php?load=" + page, { projID: projID}); break;
            case 'projShare': $("#mainRight").load("content.php?load=" + page, { projID: '5000227' }); break;

            }
            $('#mainRight').show(300);

        });

Now, basically I want the projID to be rememebred for use by other a.nav clicks that don’t supply it.

An linked anchor calling this looks like <a page="projSettings" projID="522" class="nav">Settings</a> and I’d it to save that 522. So, other requests (that don’t have the projID, as the data has been loaded into the DOM for other navs and they don’t know the projID. I hope that makes sense.

So, I’d like to know how to have links like <a page="projSettings" class="nav">settings</a> when the projID has already been used in the previous call.

Any thoughts?

  • 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-15T16:12:51+00:00Added an answer on May 15, 2026 at 4:12 pm

    Well, ironically you’re already saving projID globally (better said, within the window object by not using var in your declaration.

    So you already can access projID from everywhere in your code, once it’s initialized.

    Anyways this is not a good pratice, opposite, it’s a very bad pratice.

    The best way I can think of is to create you own application object where you store all your data and access it from there.

    var your_application = {
        var foo  = 'bar',
            base = 'ball';        
    };
    
    // your_application.foo = 'another bar';
    

    You can push this principle pretty far with using closures and functional programming. An even better solution to store and keep data local and not global (window) could look like

    var your_application = function(){
        var foo  = 'bar',
            base = 'ball';  
    
        return {
            getfoo: function(){
                return foo;
            },
            setfoo: function(newfoo){
                foo = newfoo;
            }
        };
    });
    
    var app = your_application();
    app.setfoo('foobar!');
    alert(app.getfoo());
    

    That is the idea of methodical javascript programming. There a some good books out there, I would recommend to start of with Javascript: the good parts by Douglas Crockford.

    Another solution for this should be the jQuery .data() method, which is capable of storing data in a global hash.

    // store
    $.data(document.body, 'projID', projID);
    
    // access
    var foo = $.data(document.body, 'projID');
    
    // remove
    $.removeData(document.body, 'projID');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be fairly simple question. I'm using DocX library to create new word
This should be fairly simple, but I just can't see the logic in it!
This should be easy, but I'm not sure how to best go about it.
This should be fairly simple from what I can find online, but I can't
I know this should be fairly simple but I don't get it anyhow. I've
This should be a fairly simple question but I know very little about SQL.
This should be a fairly simple question. Essentially, I believe there's a good chance
This should be a fairly simple question to answer. I looked around and couldn't
This should be fairly simple, but it is turning out to be more complicated
It feels like this should be fairly simple but nothing i've tried so far

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.