What is AJAX

AJAX is all around the internet, to name a few AJAX applications you probably use before starting more elaborate explanations, here are a few examples

  • When you visit the google website, start typing in something, and google starts suggesting search phrase / Search string in a drop down box under the search box
  • When you are composing a blog entry and it auto saves every 2 minutes
  • When you want to register an email address with a free email provider, and you stop typing the requested username for a few seconds and you see a message saying this name is not available (or is available)
  • When composing an email address, you type a few letters and your webmail starts suggesting friends email addresses that start with those letters (Or has them)

So you use AJAX every day, but you may be here to understand it rather than to know what applications are AJAX and what are not

In short, an AJAX application is in most cases an XML file on a web server, and a Javascript program that fetches it, I will assume you are not a web development professional and explain a sample simple program.

Your web browser (Internet explorer, Firefox, Safari, Etc...) is capable of executing programs, or in other words following instructions, These programs are written in Javascript, Web pages sometimes embed and send Javascript programs to your browser all the time (And some don't), but those that do can make your browser follow instructions and not only display pages.

So let us assume we have a simple XML file (Text file formatted in a certain way) on a web server or Web Site, and that XML file has a list of Countries, We will also assume you are filling in a form where in the Country field you enter United and expect a drop down box to display United States, United Kingdom, and United Arab Emirates for you to chose one and save some typing time.

So now, your browser detects that you are filling in this field, and fetches the XML file containing the list, it searches through that list for those countries that start with United, and displays the three countries in a drop down box, But what if the list has a billion names that would take forever for your browser to download, like the drop down that appears in google search ?

To write truly useful AJAX applications, you will need two things, a client side (browser) program written in JavaScript, and another written in any server side language of your choice like PHP, ASP, ASP.NET and others.

So in this case, when you use a server side programming language like PHP, your browser does not need to fetch the whole file of country names, it can pass the letters you have already typed to the server side application (Your PHP or ASP script) and that script can send a list of 3 countries rather than the whole list, Your browser would send United to the server side application, the script will send back a list of 3 countries, your browser would display them in the drop down box.

So this is a short explanation of what AJAX is, stay tuned as we get the AJAX tutorial ready for you, with cookbook examples that you can use on your website.



Copyright, V.CheapDomains 2010

Live Help