Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda