Next
Contents 
A Gentle Introduction to Ajax
A Gentle Introduction to Ajax

A Gentle Introduction to Ajax

What is Ajax?

Ajax or Asynchronous JavaScript and XML enables the programmer to execute a server-side script without refreshing the page.

Example...

Image of a Form

Traditional method

The user enters the comments and email and then clicks the submit button. The browser sends the entered data to the server-side script through the post or get method. When this is done, the browser will call the server-side script(for example a PHP page) by loading that page in the browser. This page will save the data to a database and display a 'Thank You' message in the browser.

The problem with this approch is that the users loses some time waiting for another page to load. The page cannot save the entered data without loading the PHP file.

The flow of data in the Traditional method

Ajax Method

Here when the user clicks the Submit button, a javascript function is called which loads the server-side script in the background. The user does not see it being loaded. Instead the JavaScript will immediatly remove the form from the page and show a 'Thank you' message dynamically - without reloading the page.

The flow of data in the Ajax method

Algorithm

if (user hits the submit button) {
	comment = (user submitted comment)
	email = (user's email id)
	
	//Happens in Background
	CallPage("save_comment.php?comment=" + comment + "&email=" + email);
	
	//User sees this...
	Remove(form)
	Display("Thank you for your comment.")
}

Application

The given example was for a simple application. In more advaced uses, the result generated by the called server-side script will be taken and used in the page. Some applications that would be impossible without Ajax are...

Examples of use of Ajax

Problems

Next
Contents 

Comments

Bidfreelancers at 10 Jun, 2007 05:16
Cool nice. working to implement same in one of my projects
Reply to this.
Yash at 15 Jun, 2007 11:05
yea nice basic intro
Reply to this.
bashar at 23 Jun, 2007 05:41
pretty clear and as you pointed one of the problems is the dependancy on the browser which of course have some disadvantages. so far i have seen that there are many differences between different browsers and there implementation of ajax. But anyway i think it will be more standarised soon :)
Reply to this.
Binny V A at 23 Jun, 2007 09:20
I hope so :-)
Reply to this.
jimi at 09 Aug, 2007 12:00
wow this is neat
Reply to this.
hallowreen at 07 Aug, 2007 06:25
basic intro,i like it....thanks
Reply to this.
anand at 21 Aug, 2007 04:28
Yes, it is good way.
so i used again and again in each project.
Reply to this.
Anonymous at 09 Sep, 2007 07:43
Good tutorial. Thanks
Reply to this.
Anonymous at 02 Jan, 2008 03:05
is this the ajax version?
Reply to this.
Elhusseiny at 11 Jan, 2008 12:01
Is this comment form use that Ajax???
Reply to this.
Binny V A at 12 Jan, 2008 08:04
No, it does not.
Reply to this.
Avinash at 21 Jan, 2008 09:43
hi binny,

I am a fan of u........u r simply great........really an inspiring personality.........

I am a small web developer in LAMP Platform.......ur ajax tutorial is really good.........

Avinash
Reply to this.
Binny V A at 22 Jan, 2008 12:55
Thanks :-)
Reply to this.
Avinash at 21 Feb, 2008 01:49
hi binny,

currently I am working in PHP. I am very much interested in Java and I want to work in Java platform in future. But I don't know Java. I have joined a java course in NIIT and started learning it. Shall I ask u a question ..? Can I learn java and work in it..? i have a strong desire for that.... but some of my friends discourage me saying that u r nw working in PHP and it will be difficult for u to change ur platform. Also do u knw any tutorial site for beginners like me to refer....?I went thro a cople of sites. It were all very standard ones.

hope u don't get bored...

ur's

Avinash
Reply to this.
Binny V A at 22 Feb, 2008 03:11
PHP has its advantages and Java has its. I am sure you will be able to learn Java if you want to. I don't know much about Java - so I cannot advice you on what course to take or what tutorial to look at. Sorry about that.

Changing platform is difficult - but not impossible. If you think its worth it, learn Java.

Best of luck.
Reply to this.
Matt at 31 Jan, 2008 02:11
nice.
Reply to this.
renjith at 15 Feb, 2008 07:41
hey...nice intro on AJAX..
we met at barcamp@cusat...i tried a talk with u...u werent interested :) ...so i backed off..
any way...nice article
Reply to this.
Binny V A at 15 Feb, 2008 10:55
> hey...nice intro on AJAX..
Thanks.

> we met at barcamp@cusat...i tried a talk with u...u werent interested :)
> ...so i backed off.. any way...nice article
Sorry about that - I must have been busy or something - we'll hookup in the next barcamp.
Reply to this.
Chat at 17 Feb, 2008 06:46
ur ajax tutorial is really good.........
Reply to this.
Avinash at 01 Apr, 2008 02:49
Hi binny,

Thx for ur encouragement.My Java classes r going well. One day I will also become someone..........

Shall I mail u...? I feel proud to say that u r my friend....

ur's
Avinash
Reply to this.
Binny V A at 01 Apr, 2008 12:31
Thanks - sure you can mail me.
Reply to this.
Comment


Comment




Comment Formating : HTML tags a, strong, em, b, i, code, pre, p and br allowed. Other tags will be shown as code(< will become &lt;). Urls, Line breaks will be auto-formated.