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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:47:16+00:00 2026-05-14T07:47:16+00:00

Im using a couple of JSON calls to render data, etc etc. In order

  • 0

Im using a couple of JSON calls to render data, etc etc. In order to keep the proper key value, I am storing it in a tag.

I have this in several places in my code, none of which cause an issue like this one is. Here is the jQuery:

The call that “sets” the value:

    $("a[id^='planSetupAddNewPlan']").live('click', function() {
        var x = $(this).attr('id');
        x = x.substring(19);

        $("#hidPlanSetupCurrentGroupKey").val(x);

        $.getJSON("/GroupSetup/PlanSetupAddNewList", { GroupKey: x }, function(data) {
            $("#planSetupAddNew").html('' + data.TableResult + '');


            alert('First Inside 2 ' + x);

            $.blockUI({ message: $("#planSetupAddNew") });
        });
    });

The call that “gets” the value:

$("#ddlPlanSetupAddNewProduct").live('change', function() {
            var a = $("#hidPlanSetupCurrentGroupKey").val();
            var prod = $(this).val();

            alert(a);

            $.getJSON("/GroupSetup/PlanSetupChangePlanList", { GroupKey: a, Product: prod }, function(data) {
                if (data.Message == "Success") {
                    $("#planSetupAddNewPlan").html('' + data.TableResult + '');
                } else if (data.Message == "Error") {
                    //Do something
                }
            });
        });

Here is the html in question:

<div id="planSetupAddNew" style="display:none; cursor: default;">
    <input type="hidden" id="hidPlanSetupCurrentGroupKey" />
    <div id="planSetupAddNewData">

    </div>
</div>

In the first section, the alert (‘First Inside 2 ‘ + x) returns what I expect (where x = the key value), and if I add a line to display the contents of the hidden field, that works as well:

ie.

var key = $("#hidPlanSetupCurrentGroupKey").val();
alert(key);

In the “alert(a);” call, I am getting “undefined”. I have looked at the other code in the same view and it is the same and it works. I must be missing something, or have some sort of mistype that I havent caught.

Just an overview of the controller events:
The first call (/GroupSetup/PlanSetupAddNewList) will return an html string building a “form” for users to enter information into.

The second call (/GroupSetup/PlanSetupChangePlanList) just changes a second dropdown based on the first dropdown selection (overwriting the html in the div).

If you need more info, let me know!

Any thoughts/tips/pointers/suggestions?!?!

Thanks for all 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-05-14T07:47:16+00:00Added an answer on May 14, 2026 at 7:47 am

    Why not use a normal javascript global variable?
    Or use jQuery’s data

    var globalGroupKey = '';
    $("a[id^='planSetupAddNewPlan']").live('click', function() {
        var x = $(this).attr('id');
        globalGroupKey = x.substring(19);
        $.getJSON("/GroupSetup/PlanSetupAddNewList", { GroupKey: globalGroupKey }, function(data) {
            $("#planSetupAddNew").html('' + data.TableResult + '');
    
    
            alert('First Inside 2 ' + x);
    
            $.blockUI({ message: $("#planSetupAddNew") });
        });
    });
    
    $("#ddlPlanSetupAddNewProduct").live('change', function() {
            var prod = $(this).val();
            alert(globalGroupKey);
            $.getJSON("/GroupSetup/PlanSetupChangePlanList", { GroupKey: globalGroupKey, Product: prod }, function(data) {
                if (data.Message == "Success") {
                    $("#planSetupAddNewPlan").html('' + data.TableResult + '');
                } else if (data.Message == "Error") {
                    //Do something
                }
            });
    });
    

    Anyway, this looks to me like the change event is firing before click, so probably nothing of this will work.

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

Sidebar

Related Questions

I have been using the CSLA framework for couple of years now for windows
We have a couple of web servers using load balancer. Machines are running IIS6
I have a couple of Divs which I style using a class and an
I'm using a couple of Grid s to format multiple GridViewColumn.CellTemplate s: <ListView SharedSizeScope=true>
I've tried using source control for a couple projects but still don't really understand
I am currently using TortoiseSVN to manage a couple of the projects that I
I've been using JSch for a couple of weeks now. It seems to work
I've been using Emacs for a couple months now, and I want to get
I've been using Git now for a couple of months on a project with
I've found a couple of references ( for example ) that suggest using final

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.