<$BlogRSDUrl$>
Ram's Perspective
Just another blog portraying a 23 year old software engineer's view on anything, everything and nothing

The Warrior Prince

Thursday, March 02, 2006
Warning: If you are not interested in Computers and tech stuff please Skip this post.

Warrior prince who was huge and strong, but slow in speech. His father was king Telamon of Salamis. He was considered the second greates warrior after Achilles, and he was the one who carried the hero's dead body back to the camp while Odysseus held the Trojans back.
Who is this Prince?
He is AJAX. This word is popular in another field too, yes it is one of the buzzwords in Software Industry now. I just tried a sample application with this technology, just thought i cud blog about it. I am not going to brag about my application coz there is nothing in it. It is very simple.
AJAX stands for Asynchronous Javascript and XML. Initially when i heard about it i thought of AJAX as some hi fi tech stuff, and when ppl said "You can update the data in WebPage without refreshing it " i confirmed that. But atlast it turned out to be simple and so simple like ordinary "HttpRequest". The core object of this AJAX is a seemingly new object called "XMLHttpRequest" why is this special? and how is this different from the former? will be the next question. The answer is it is not special but different from a "HttpRequest" object. Basically there are 2 differences:
1. It implicitly provides support for XML(which is the standardised data transfer method).
2. It has the ability to connect to the server and get the information without the knowledge of the User, i mean the request -> server -> response cycle happens in background.
Initially i had a misconception that this is called Asynchronous because of the background process stuff, but i was wrong.Thanks to the Google and its results that cleared my doubts. This is called Asynchronous because of the following reason:
In ordinary Requests stuff, the user will have to wait in the same window until the server's response is completely received by the browser, i.e u have to be in sync. But in case of XMLHttpRequest, there is a flag attribute which when set appropriately allows you to be out of sync, i.e. you can proceed to the next action without having to wait for the server's response. This can be made synchronous also. The XMLHttpRequest can call almost all kind of requests that can be made via an ordinary browser.
Another misunderstanding about AJAX was that it is a cutting edge technology. No its not it is already around 10 years old(i dont have proof for it) jus heard it from a senior. Biggies like Microsoft and Google have been using AJAX in the past, Google maps is an example. Now lets look at the pros and cons. Before which i ll have to mention a disclaimer.
Disclaimer:
I have not used AJAX intensively, so these info may not be accurate, i am writing what i feel about this technology.

Pros:
-----
1. You need not refresh the page boss, which saves time.
For eg. you have around 10 fields in a screen of which only 2nd-5th have to be autopopulated based on the first field and the fields 7-10 have to be autopopulated based on the 6th field. You need not refresh/reload or click the buttons in the page twice to autopopulate the details. Instead it will be done automatically as you enter the values, another striking example is auto completion of forms.
In short your application will behave like a standalone Desktop Swing/VB like application instead of a Web App.
2. Since it supports direct XML response you can render the incoming data easily using some stylesheets.
3. Asynchronous mode, no waiting until server responds, proceed with the next fields.
4. Improves the User experience.

Cons:
-----
1. Since the process happens in background, if there is some problem in the server's response we may not know directly coz in the normal case browser will display a "404" or "500" error, but here we have to explicitly handle these kinda errors by getting the status code manually.
2. It does not suit every application. Whenever we hear about something new we ll have enthu to use it imme (i am one of them), but we shud not do that mistake here.
3. One more con is that when you use GET method for Http requests, the browser will cache the response and will not retrieve the latest data , the remedy for this will be:
i.add a timestamp to the end of request URL.
ii. use POST method.

A typical use of AJAX wud be, most of us wud have noted that when we republish our entire blog we see the page being auto refreshed while showing the progress if we use AJAX we can make this progress bar behave like a Windows component and no need to auto refresh atleast for the User, coz actually it refreshes the data.

Now i ll tell about my Application. I just wrote a simple html with Javascript, which will display the netstat info of a remote UNIX server each 30 seconds without refreshing the page. The server side component was a single CGI script.
AJAX is not supported by all browsers, currently Opera 7.0 doesnt support it so we ll not be able to use full features of Gmail etc. in Opera.

For those who are interested in further study visit this link.

For ppl who came thru' this patiently please dont curse me for an inappropriate title. :-)

Cheers,
Ram
7:27 AM :: ::
7 Comments:
  • hey ram.busy huh?u have been dormant for the past two weeks.out of station?

    By Blogger paurna, at 8:47 AM  
  • no da jus some renovation work in home so cudnt use system

    By Blogger Ram, at 8:51 AM  
  • Hahaha. I was wondering if my eyes reading wrong title :P
    U are using Dinakaran technique..Where in there wont be any relation btwn the title and the content except for a line.

    Have a nice day,
    Ponnarasi

    By Blogger Ponnarasi Kothandaraman, at 11:20 AM  
  • @ponnarasi
    Chumma thaan....

    By Blogger Ram, at 8:23 AM  
  • Good design!
    [url=http://bgguinwp.com/zghp/fueq.html]My homepage[/url] | [url=http://pimxmzuu.com/brhy/lxlo.html]Cool site[/url]

    By Anonymous Anonymous, at 5:00 PM  
  • Well done!
    My homepage | Please visit

    By Anonymous Anonymous, at 5:01 PM  
  • Thank you!
    http://bgguinwp.com/zghp/fueq.html | http://kpuprsbz.com/gkbr/pfqe.html

    By Anonymous Anonymous, at 5:01 PM  
Post a Comment
<< Home

Ram :: permalink