PDA

View Full Version : Ajax Date-Based Fetch Problem


Firebug
03-08-2010, 09:52 PM
Hello,

I'm new to Ajax use, forgive me If I am asking a repeated question here, but I have not found my answer yet.

I'm trying to fetch pages based on the current date settings for the user (I know this my cause issues with users who have incorrect date settings). Then, the page that is fetched should populate based on how many days of the month have passed.

My issue is that the "sorted" data on the fetched page does not show up, and all I can see is the basic HTML content. Does Java not run when fetched via ajax?

Here is my code for the page that fetches (using ajaxpagefetcher.js downloaded from http://www.javascriptkit.com/script/script2/ajaxpagefetcher.shtml).


<div id="DynamicEvents"></div>

<script type="text/javascript">

var thedate = new Date();

var monthofyear = thedate.getUTCMonth();


switch(monthofyear)
{
case 0: ajaxpagefetcher.load("DynamicEvents", "January.html", true); break;
case 1: ajaxpagefetcher.load("DynamicEvents", "February.html", true); break;
// case 2-10 will grab months in between
case 11: ajaxpagefetcher.load("DynamicEvents", "December.html", true); break;
default: document.write('Error On Page');
}
</script>


And a snippet from the page that loads in, in this case, March.


<h3>March Events</h3>
<b>

<div id="event01name"></div>
<div id="event01time"></div>
<div id="event01space"></div>

<script type="text/javascript">

var thedate = new Date();

var dateofmonth = thedate.getUTCDate();

// 03-09-2010
if(dateofmonth <= 9)
{
var div=document.getElementById("event01name")
var textnode=document.createTextNode("3/9\xA0\xA0\xA0\xA0 Meet the Dietitian - Bob's Place")
div.appendChild(textnode)
var div=document.getElementById("event01time")
var textnode=document.createTextNode("\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 4:30 pm - 7:00 pm")
div.appendChild(textnode)
var div=document.getElementById("event01space")
var textnode=document.createTextNode("\xA0\xA0\xA0\xA0\xA0")
div.appendChild(textnode)
}

//Other if statements as needed for events.

</script>


Currently all that shows when the page loads is: March Events

Any help is appreciated!