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

206
Views
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
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!