Where Knowledge Rules

Computers & Technology:

Internet

Get a Widget for this title

Ajax web technology explained

= new XMLHttpRequest();

Let us call this variable, the Ajax Object. Well, there is trouble; the above code works in Mozilla Firefox, Netscape and other major browsers except Internet Explorer. Internet Explorer versions would not produce the Ajax object using the above constructor function. These versions have their own constructor functions to produce the Ajax object. The different Internet Explorer versions can be grouped in three sets based on three different constructor functions they use to produce the Ajax object. One set produces the object as follows:

var myAjax = new XDomainRequest();

Another set produces the object as follows:

var myAjax = new ActiveXObject("Msxml2.XMLHTTP" );

The last set produces the object as follows:

var myAjax = new ActiveXObject("Microsoft.XMLHT TP");

In order to write code that will work for major browsers, you need an "integrated" try-catch-block as the following code segment illustrates:

var myAjax;

try
{
// Firefox, Opera 8.0+, Safari
myAjax = new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
myAjax = new XDomainRequest();
}
catch (e)
{
try
{
myAjax = new ActiveXObject("Msxml2.XMLHTTP" );
}
catch (e)
{
try
{
myAjax = new ActiveXObject("Microsoft.XMLHT TP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
}
}
}
}

The first thing in the code segment above is the declaration of a variable, which the Ajax object created will be assigned to. As you can see, the first try-catch is for non-Internet Explorer browsers. The rest of the try-catches are for different versions (three sets) of Internet Explorer. If none of the tries work, then it means the user's browser is not a major browser and does not support Ajax; an alert box displays this.

After creating the Ajax object, the object has to achieve the above three objectives, which are repeated below:

- Open a connection between the client computer and the server.
- Send the request for the information (text) the user needs.
- Wait for the response and receive it.

The GET and POST methods
Before we look at the first objective above, we have to know that there are two methods by which a request can be sent by the Ajax object to the server. They are called the GET and the POST methods. Now, these methods are not the Ajax object methods. They are actually called HTTP methods. Well, you do not need to understand HTTP in order to understand this article (or Ajax - the topic).

The difference between the GET and POST methods is not in the meanings of the word GET and POST.


Below are the top articles rated and ranked by Helium members on:

Ajax web technology explained

  • 1 of 5

    by AJL

    I cannot express how much I really LOVE AJAX. I have been a web developer for the past 8 years and I have to say that microsoft's

    read more

  • 2 of 5

    by Obsidian

    What is AJAX? Well, the textbook definition, Asynchronous JavaScript and XML, is not of much help to the average reader

    read more

  • 3 of 5

    by Chrys

    Making Ajax Request
    Ajax Web Technology Explained Part 1

    Introduction
    This is part 1 of my article series, Ajax Web Technology

    read more

  • 4 of 5

    by Fred Lawrence

    The acronym Ajax meaning Asynchronous Javascript and XML,refers to the use of several web technologies in an application

    read more

  • 5 of 5

    by ARC IDEA CO

    In e-business's point of view, in order to appeal to its customers of clientele, you need to have a website or a web front.

    read more

Add your voice

Know something about Ajax web technology explained?
We want to hear your view. Write_penWrite now!

Helium Debate

Cast your vote!

Pornography on the Internet: Free speech or subject to regulation?

Click for your side.

175649

Featured Partner

National Center for Policy Analysis (NCPA)

The National Center for Policy Analysis (NCPA) has partnered with Helium, giving you the chance to write for a cause....more

What is Helium? | Buy Web Content | Contact Us | Privacy | User agreement | DMCA | User Tools | Help | Community | Helium’s Official Blog | Link to Helium

Helium, Inc.
200 Brickstone Square Andover, MA 01810 USA