Search code examples
javascriptjqueryjsondatejs

jquery object issue with ie9 and opera


I have been trying to get a script to work on my site and it works on Chrome, Safari, and Firefox, but not on IE 9 (it will work in compatability mode) or Opera. Is there an issue that I'm not catching?

Here is the Script:

$(document).ready(function(){
$.getJSON('/storage/xml/biblereading2.json', function(data) {
today = Date.today();
var name = today.getDay();
var date = today.getDate();
var month = today.getMonth();
var year = today.getFullYear();
var fullday = name.toString();
var todaydoy = today.getDayOfYear();
var todaywoy = today.getWeekOfYear();
//array for months
fullmonth = new Array (12);
fullmonth[0] = "January";
fullmonth[1] = "February";
fullmonth[2] = "March";
fullmonth[3] = "April";
fullmonth[4] = "May";
fullmonth[5] = "June";
fullmonth[6] = "July";
fullmonth[7] = "August";
fullmonth[8] = "September";
fullmonth[9] = "October";
fullmonth[10] = "November";
fullmonth[11] = "December";
fullday = new Array (7);
fullday[0] = "Sunday";
fullday[1] = "Monday";
fullday[2] = "Tuesday";
fullday[3] = "Wednesday";
fullday[4] = "Thursday";
fullday[5] = "Friday";
fullday[6] = "Saturday";
var s = todaydoy - 1;
$("#biblereading").append('<p><span class="bold_font">Bible Reading for Today:</span>  </br>' + fullmonth[month] + ' ' + date + ', ' + year + '</br>' + data.schedule[s].portion.reading + '</br></p>');
});
});

I'm using date.js to handle the date issues in the first several variables, an array to give the spelled out month and day, and I'm calling a json from the same server.

Opera keeps telling me that I have a TypeError at data.schedule[s]

and IE 9 keeps telling me that I have an undefined or null value at data.schedule[s].

Any Ideas? (you can see this attempt at implementation http://rosemontbaptist.com on the front page.


Solution

  • If you log what todaydoy is

    var todaydoy = today.getDayOfYear();
    

    You will see it is returning the wrong value in IE, the following is copied from the watch window in IE9's console.

    todaydoy    694324  Number
    

    You need to figure out if their is bugs in the Date library you are using.