Saturday, February 19, 2005

Floating calendar - JS+XMLHttp+PHP+XML

Gone are the days of Websites and Webpages. Its all Web-applications now. And the recent hype seems to be centered around XMLHttpRequest and DOM,DHTML. From Google-maps to Switzerland-maps (doesnt use flash, XMLHttp but DHTML based tiling), new technology is creating richer and more useful web-content. I thought to have a quick glance at XMLHttp since I already have some experience in DHTML (this page was created when DOM was not in full effect and cross-browser coding was a major headache; so you need Netscape 4.7 or IE 5.0 to view this page. I did not update the page to use DOM so recent browsers will not work). But first I need to think of some useful application. Thinking... thinking... thinking...

How about a floating calendar. Like the one here (calendar icon at the top-left corner). I can put such a calendar on my blog page. At the backend I would just have to write a small tool to feed the events (that I want to share) to an (XML) file (which will stay on my server). So, whenever any user clicks on a date, the event information for that date will retrieved from the XML file via a (PHP) script using XMLHttpRequest which can then be displayed. Cool! I like the idea.

How should I start ... IE and mozilla have different ways of creating XMLHttpRequest object. And then again, for old browsers, I have to use the old style of accessing div. While its not impossible to write them from scratch, its easier to use an existing one. The rest was smooth. Created a simple xml event file and a simple php script to parse the xml file on request and retrieve the event for a given date.

Everything worked, except the most crucial part. I soon came to realize that under normal browser-security policy, XMLHttpRequest can only query the same server as the current web-page. That means I cannot have the events file on my server and calendar on the blogger server.

Without trying further, I put the calendar on my start page and stopped worrying about XMLHttpRequest for the time being. If anybody has a better idea (other than hosting my blog on my own server), please let me know.

- d.

No comments:

Post a Comment