I came across a case when I created an event calendar with javascript the developer didn't provide any documentation how to fetch the json data from the url, So finally I had to create my own ajax data fetch function. But it didn't run, so I ended up using file_get_content php for the time being but it looks untidy, I searched on the internet finally I found this and will reshare here.
const ajaxData = $.ajax({
url: "data.json",
global: false,
type: "POST",
dataType: "jsonData",
async:false,
success: function(msg){
return msg;
}
}).responseText;
console.log(JSON.parse(ajaxData));
Then I called this global variable in the calendar function, I finally managed to run it.
0 Comments