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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:47:15+00:00 2026-06-17T21:47:15+00:00

The pastPath variable in the code below is confusing me. I normally use C#

  • 0

The pastPath variable in the code below is confusing me. I normally use C# and MVC which of course means I use HTML, JavaScript, and JQuery along with other associated web / mobile technologies.

When I run this code and click the .moreBtn pastPath reports it is set to the URL as I intended. Yet when I try to use .backBtn to set the URL and force my browser to go back to the previous page, I get either that pastPath is undefined, or that it is set to hello.

I know I am having a problem understanding scope here. I have read articles on JavaScript scope but I am wondering instead if someone can resolve this problem and explain how I get my URL from the first function into the second.

I will read more about scope in JavaScript later but it seems very different to scope in most other languages and I presently don’t have time to look into it properly.

$(document).ready(function ()
{
    pastPath = "hello";

    $(".moreBtn").click(function ()
    {
        var controller = $(".moreBtn").data('ctrl');
        var action = $(".moreBtn").data('action');
        loc = GetPathDetails("full"); //This simply returns the part of the URL I need.
        pastPath = loc;
        alert(pastPath);
        var fullPath = loc + "/" + controller + "/" + action;
        window.location = fullPath;
    });

    $(".backBtn").click(function ()
    {
        alert(pastPath);
        //window.location = pastPath;
    });

});

Thanks for your help.

  • 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-17T21:47:16+00:00Added an answer on June 17, 2026 at 9:47 pm

    The .moreBtn click changes the page so any data you store in pastPath will be lost.

    Have a look at dom storage, https://developer.mozilla.org/en-US/docs/DOM/Storage

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

Sidebar

Related Questions

I have these two functions below and for whatever reason the windowedBox function only
I have the following code: - (void) likeImage:(AHInstagramImageData *) image success:(void (^)(BOOL success))success failure:(void
I am making use of AFNetworking library for the first time and i have
I'm having trouble uploading an image with data. This code allows me to upload
I am using a notification system on node.js and i am trying to use
While attempting to use the CopyFile() function I have encountered a strange error. It
I have the following code that fetches some data from a php script. I'm
I am trying to find a way, using AFNetworking, to set the Content-Type header
I hava a notification system in my site and I am trying to change
I defined a block in a class: BXButton.h typedef void(^ButtonClicked)(id sender, NSDictionary *userInfo); @property

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.