I am stuck here and hope to get some guidance on this. I'm trying to take XML from a feed, put some elements into an array, then pass into jQuery's DatePicker plugin. My code below is displaying the calendar, but not the events from the feed. Chrome is show no errors or warnings either. Not sure what's going on. Any assistance is much appreciated.
(My XML):
<entry>
<published>2012-05-29T13:05:53-08:00</published>
<updated>2012-05-29T13:05:58-08:00</updated>
<title type="html">
<![CDATA[ Businesses Get Help With Legal Issues ]]>
</title>
<content type="html">
<![CDATA[ Click the article header for the complete story.
<!-- /Publications/26674.htm -->
]]>
</content>
<link rel="alternate" type="text/html" href="/Publications/26675.htm"/>
</entry>
(In external JS file):
$(document).ready(function(){
var events = new Array();
events = getSelectedDates();
$("div.datepicker").datepicker({
beforeShowDay: function(date) {
var result = [true, '', null];
var matching = $.grep(events, function(event) {
return event.published.valueOf() === date.valueOf();
});
if (matching.length) {
result = [true, 'highlight', null];
}
return result;
},
onSelect: function(dateText) {
var date,
selectedDate = new Date(dateText),
i = 0,
event = null;
while (i < events.length && !event) {
date = events[i].published;
if (selectedDate.valueOf() === date.valueOf()) {
event = events[i];
}
i++;
}
if (event) {
alert(event.Title);
}
}
});
});
function getSelectedDates()
{
var the_selected_dates = new Array();
$.ajax(
{
url: 'news.xml',
type: 'GET',
dataType: 'xml',
async: false,
success: function(data)
{
$(data).find('entry').each(function(i, entryObj)
{
var entryObj = new Object();
entryObj.eTitle = $('title', this).text();
entryObj.eDate = $('published', this).text();
the_selected_dates.push(entryObj);
});
}
});
return the_selected_dates;
}