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

208
Vistas
How to get the variable from JSON file and assign to another variable in the array using javascript?

I am successfully able to fetch a json file saved on the server. Now I want a specific value which needs to be assigned, and use it inside another array as a variable.

I want this value to come from a JSON file saved through mySQL, and use the value in the calendar.

The code I have got is:

  var  events = []; // I wanted to use inside this array.
   
  var gettitle = "";

  $.getJSON(fileLocation, function (data) {  //file is getting fetched successfully.

    $.each(data.data, function(i, v) {   // there are two records and  able to fetch each of them.
         gettitle = v.title; 
         alert(gettitle); // alert both the titles. 
    }); 
});

events = [
  {
    id: 1,
    url: '',
    title: gettitle, // when i use the variable here, it is not displaying anything. just a calendar starting with Dec 2021 Month
    start: date,
    end: nextDay,
    allDay: false,
    extendedProps: {
      calendar: 'school'
    }
  }];
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