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'
}
}];