After much struggle, I have been able to muddle my way through to get the code to this point, but I am stumped as to why its not sending the JSON data to the HTML via JavaScript. I can open the developer console and manually type on the parts after onLoad, and it works... But running the script by itself so it automatically populates the empty divs on the page - absolutely nothing... I know its probably something stupid and small I am over looking - but I'm at a point where I want to move on from this stupid part of the site. any help would be much appreciated.
/* General Info */
/* Data Routing Structure: */
/* (JSON DATA) (jsVariable) (cssID) */
/* title rTitle rTitle */
/* quote rQuote rQuote */
/* source rSource rSource */
/* text rText rText */
/*---------------------------------------*/
/* All JSON Data Files Are Located In */
/* (Root)/dta, And Are Split Into 12 */
/* Files.
/* Define Global Variables To Help */
/* Specify The Current Day And Month */
var date = new Date();
var m = date.getMonth();
var d = date.getDate();
var months = new Array()
months[0] = "january";
months[1] = "february";
months[2] = "march";
months[3] = "april";
months[4] = "may";
months[5] = "june";
months[6] = "july";
months[7] = "august";
months[8] = "september";
months[9] = "october";
months[10] = "november";
months[11] = "december";
var month = months[date.getMonth()];
/* Make The Connection To The JSON File */
var drOb
var xhr = new XMLHttpRequest();
xhr.open('GET', "./dta/" + month +".json");
xhr.overrideMimeType("application/json");
xhr.setRequestHeader("Content-type", "application/json", true);
/* Pull JSON Data For Todays Date */
/* When The Page Loads, And Send To HTML */
xhr.onLoad = function()
{
if (this.readyState == 4 && this.status == 200)
{
var drOb = JSON.parse(this.response);
var rDate = m + d;
var rTitle = drOb[DAY][d].TITLE;
var rQuote = drOb[DAY][d].QUOTE;
var rSource = drOb[DAY][d].SOURCE;
var rText = drOb[DAY][d].TEXT;
document.getElementById("rDate").innerHTML = rDate;
document.getElementById("rTitle").innerHTML = xhr[DAY][D].TITLE;
document.getElementById("rQuote").innerHTML = rQuote;
document.getElementById("rSource").innerHTML = rSource;
document.getElementById("rText").innerHTML = rText;
}else{
alert("Daily Reflection is currently not available, please inform someone....");
}
};
xhr.send();