Home arrow AJAX & Prototype arrow Page 3 - The Ajax Approach to ACP: A Simple Example

The Script in the DIV in the BODY - AJAX

This is the third part of my four-part series, "Active Client Pages, An Ajax Approach." In this part I illustrate the Ajax approach with a simple example, complete with code. Be sure to read the first two parts; they will help you understand what I'm trying to accomplish here, though the first part of this article does include a quick summary.

TABLE OF CONTENTS:
  1. The Ajax Approach to ACP: A Simple Example
  2. The Simple Example Code
  3. The Script in the DIV in the BODY
  4. The Back Button
By: Chrysanthus Forcha
Rating: starstarstarstarstar / 4
October 21, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

In this section, I talk about the script at the bottom of the first page. This script is in the BODY element. Remember that JavaScript in the HEAD element is executed when it is called, while JavaScript in the BODY element is executed when the page is loaded. This is the script:


<script type="text/javascript">

 

var xmlHttp;

 

try

{

// Firefox, Opera 8.0+, Safari

xmlHttp=new XMLHttpRequest();

}

catch (e)

{

// Internet Explorer

try

{

xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

}

catch (e)

{

try

{

xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

}

catch (e)

{

alert("Your browser does not support AJAX!");

}

}

}


xmlHttp.onreadystatechange=function()

{

if(xmlHttp.readyState==4)

{

theArray[2] = xmlHttp.responseText;

}

}

 

xmlHttp.open("GET","sendText.pl",true);

xmlHttp.send(null);

</script>


The features here are the same as in the previous part of the series. The only difference is that, in the previous part of the series, all of these statements are in a function. Here they are not in a function, so they are executed as the page is loaded. I will not repeat the explanation of the code.

The complete code can be downloaded at:


ajaxApproach.ZIP




 
 
>>> More AJAX & Prototype Articles          >>> More By Chrysanthus Forcha
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

AJAX & PROTOTYPE ARTICLES

- Best AJAX Tutorials for Forms
- The Best AJAX Tutorials
- 8 Great Ajax Tutorials
- Using Ajax and jQuery
- Using Ajax and jQuery with HTML Forms
- Ajax.org Offers Cloud9 IDE for JavaScript
- Java Technologies Provider ICEsoft Releases ...
- Using Recaptcha in AJAX Prototype Framework ...
- Google's Closure Compiler Service API: Addit...
- Installing Google Web Toolkit: Introducing t...
- Google's Closure Compiler Service API: Displ...
- Google's Closure Compiler Service API: Deliv...
- Google's Closure Compiler Service API: the A...
- Google's Closure Compiler Service API: the S...
- Google's Closure Compiler Service API: Optim...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: