Posts tagged ‘AJAX Basics’

Aug 7 09

AJAX 101 – part 2

Creating an object-oriented AJAX engine

Once there is an understanding of the AJAX engine the focus can be on the actual response and page display; this is where the real power lies. Since rewriting the engine for each project is tedious and time consuming, an object-oriented solution can be very useful. This kind of engine can be reused for all of your AJAX projects and scaled to meet different projects’ needs.

An object-oriented AJAX engine will also help you separate your interface code from your request data, which will enable you to reuse this engine in multiple projects. The AJAX engine is not difficult to construct once you understand the syntax for creating custom JavaScript objects. The first step is to create a constructor function, which will be the access point to the object.

function Ajax() {
	this.toString = function() {return "Ajax"; }
}

read more…

Jun 21 09

AJAX 101 – part 1

AJAX, an acronym for Asynchronous JavaScript and XML, is a group of technologies combines to accomplish powerful new forms of the web interactions. It’s composed of JavaScript, the XMLHTTPRequest object and XML, JSON, (X)HTML or even plain text.

Asynchronous means that you can make an HTTP request to a server and continue to process other data while waiting for the server’s response. For example, you can make requests to a server-side script to retrieve data from a database as XML, send data to a server-side script to be stored in a database or simple load a static XML file to populate pages of your web site without ever refreshing the page.

Behind the scenes data transfers are accomplished through the XMLHTTPRequest object, which is the heart of the AJAX engine, as it’s used to exchange data asynchronously with a server-side language, XML or other text format. It combines with the DOM (Document Object Model) to display the AJAX response data as (X)HTML and CSS.

The DOM is a language-independent interface that makes common web page elements accessible through scripting languages. This is extremely useful when working with dynamic data, such as an AJAX response, because it can be parsed by JavsScript and added to page elements on the fly without a browser refresh.
read more…