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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:00:36+00:00 2026-05-26T22:00:36+00:00

var s = store.get(‘billablexxxx’); if (!s) { if (false) { s = { something

  • 0
var s = store.get('billablexxxx');
if (!s) {
    if (false) {
          s = { 
             "something" : 'Value', ....
          }
     }
 }else {
        s = new Object;
        $.getJSON('Translation/GetIndexLabels', function(data) {
            $.each(data, function(key, val) {
             s[key] = val;
          //    temp[key] = val;
           })}) ;
    }
}
//here i use the variable

But where i use the variable, the dynamic properties dissapaered, it’s not undefined but it’s an empty object.
However, when it has been set in the $.getJSON() function, all values are added.

What did i do wrong?

Edit:
Fixed the problem by putting it into a function. When i posted the question, i was already close to the answer that i have looked for the last “hour” (weird javascript console results brought confusion).

Thanks for the advice!

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

    The call to $.getJSON() is asynchronous, so the execution will reach the part where you “use the variable” before the asynchronous call completes.

    The usual way to deal with this is to have the use of the variable inside a callback function that is referenced in the getJSON() call.

    Here’s the reference: http://api.jquery.com/jQuery.getJSON/

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

Sidebar

Related Questions

var htm = $.ajax({ type: GET, url: ./viewforms, async: false }).responseText; var myObject =
How can I get JSON array from Ext.data.Store outside the function? The code: var
I've configured my store as: var store = new Ext.data.JsonStore({ url: 'gridData.php', root: 'movies',
var y = new w(); var x = y.z; y.z= function() { doOneThing(); x();
var insInvoice = new NpgsqlCommand( @INSERT INTO invoice_detail( invoice_id, invoice_detail_id, product_id, qty, price, amount)
var newUser = new tblUser() { Email = strEmail, Password = strPassword, DateBirth =
var store = GetStore(); using (IsolatedStorageFileStream fileStream = store.OpenFile(RootData, FileMode.Create)) { DataContractSerializer serializer =
I have a Store that contains a list of Products : var store =
I can't manage to get this Ext.data.XmlReader's CDATA field mapping to work. <script> var
I'm new to jQuery and JavaScript I have managed to get a small snippet

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.