Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Call variables outside getJSON

I am wondering if I can call variables outside the getJSON, having a multilingual website, json file looks like (lang_fr.json, lang_en.json):

{
    "HOME": "Home",
    "ABOUT": "About",
    "CONTACT": "Contact us",
    "EMAIL": "E-mail Id",
    "CHOOSE_FILE": "Please choose at least one file",
    ETC
}

I all the getJSON, and would like to store variables, to use them later on the page, it can be error messages to display, or a menu,..

$(document).on('click', '#upload', function () {

// some code goes here

    $.getJSON('cdns/json/lang_' + memLang + '.json', function (dlang) {
      console.log(dlang);

      var  storeKeys  = [];
      var  storeVals  = [];
      $.each(dlang, function(x, y){
        storeKeys.push(x);
        storeVals.push(y);
      });
    });

    console.log(storeKeys); // empty
    console.log(storeVals); // empty

Then try to get these variables to use down:

/*** Some code goes here */

let choosefile = storeKeys.CHOOSE_FILE;

if (!fileValue) {
            $('#loadingResult').html(choosefile);


//End code
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!