Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

212
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda