Wednesday, June 08, 2005

An AJAX hack gone bad...

The latest buzz over the web these days is AJAX aka XMLHttpRequest . I thought I should at least try to find out what it is, so I somehow managed to dig up this site . There are two files client.html and server.php which demostrate AJAX. Now what is interesting to note is, that the "server" need not be a PHP etc file as long as what it spews out is XML.
I thought this can be used to somehow serve content remotely. Suppose you have a web site and are running short of storage space, which is obviously expensive. What you could do is store your HTML document in an encoded format in one of the free web hosts found over the web and use XMLHttpRequest to fetch the page for you. Thus you don't need to worry about the ads of the free web hosting site (ads are placed on HTML documents and we will be using a text file).
The encoding could be the one like which we have at osix, meaning using a '[' and ']' instead of a '<' and '>' for html tags.
For an example check this

The client will request for the document using AJAX and then parse it, basically replacing each '[' and ']' with a '<' and '>' and then display the page by (maybe) using document.write .

It looked to me that it will work and it even did when I tried it locally on my PC. But unfortunately when I try to do it over the internet it doesn't work. In my case I uploaded the client over at geocities and the server (the document which has to be served, rather) here at osix. But when I run the client nothing happens. Is it because the request is coming from another domain name ? If I keep both the client and server in the same directory at geocities it works.

Anyone know what is going wrong. Is, what I am trying to do even possible??

No comments: