Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we do AJAX programming

Tags:

ajax

I have no idea about AJAX programming features. I just know that it is Asynchronous Javascript and XML. Please help me in knowing about this language. I have gone through many AJAX tutorials. But none of the programs are running. Why I don't know. Do we save the file with .HTML extension?

like image 423
Sonali Avatar asked Jun 05 '10 05:06

Sonali


2 Answers

Read:

AJAX Tutorial by W3Schools.

AJAX Programming by Google Code University

To start coding you can get the Ajax Control Toolkit by Microsoft. You should read Ajax Control Toolkit Tutorials to get a grasp of it.

You can use the free Microsoft Visual Web Developer 2010 Express Edition as your IDE.

like image 110
Leniel Maccaferri Avatar answered Nov 16 '22 21:11

Leniel Maccaferri


Aside from the correct responses that the others gave you, judging from your question I think you first need to learn about client-side and server-side code.

Do we save the file with .HTML extension?

Yes and no. You will have an HTML frontend, that for instance contains a button. This will be interpreted from the client's (=user) browser. In fact it may be rendered differently depending on the browser/OS/etc.

Now, you attach some Javascript code to this button. This also runs on the client's browser, and creates a XMLHttpRequest object, either directly or through the use of a library (JQuery & Co.). Note that a library is not necessary to do an AJAX request. It will make your life easier if you do a lot of AJAX calls, but it is not essential.

And here's where the magic happens: the XMLHttpRequest object will call asynchronously (i.e.: without reloading the page) a server-side page. This may be a PHP, ASP, Perl etc etc file that does something on the server, for instance queries a database. This part of the operation is absolutely independent from the client. The user can close the browser before the server-side code finishes to load and the server will not know about it.

Once the server-side code has finished executing it returns to the client with some response data (e.g. a piece of XML, JSON, HTML or whatever you like). Finally the client executes (or not) some other Javascript code in response to this, for example to write on the screen, again with no reloading of the page, something based on what the server has returned.

like image 24
nico Avatar answered Nov 16 '22 22:11

nico