An Ajax Approach to Active Client Pages

If a user were using a slow Internet connection, he would have found that it takes time for him to have his web page displayed (downloaded) at his client computer. Nowadays, only the first page of his web site will take a long time to be downloaded; the rest of the pages will come very fast. Keep reading to learn how we can accomplish this trick. It’s all thanks to Active Client Pages and the magic of AJAX.

Active Client Pages – Ajax Approach

Introduction

If you have a web site with an image gallery, and your users are using a slow Internet connection, the pictures will take a long time to be downloaded. But now, you can set things up so that only the first image (or first set of images) from your web site will take a while to be downloaded; the rest of your images will come very fast.

If you are working from a database at a server (web development) and your server is too busy because many people are using it, I have good news for you: you can have the database programming activity, which is supposed to happen at the server, be performed at the client’s computer instead. Many professional web sites use server-side applications like PHP, ASP, JSP etc. to generate their pages. If you are good in JavaScript and do not want to pay more for hosting because of active server page technology, the time has come for you to pay less, and not use active server pages.

Web pages are becoming voluminous because authors like to make them active; because of this, the pages take time to be downloaded. But you can now have your web page downloaded in bits, thanks to Active Client Technology, discovered by Vlad Podvorny in the years 2002-2003 and Chuck Bradley in the year 2006, and enhanced by me, Chrysanthus Forcha in 2007. Both Vlad and Chuck gave the name Active Client Pages (ACP) to the discovery, even though they discovered it independently.

You need good knowledge of JavaScript, HTML and Perl in order to understand this four-part series.

How I became interested in Active Client Pages

I am a freelance computer programmer. One of my clients, whose users have slow Internet connections, asked me to do some simple web development for his transport company. He has inter-city buses and he wanted people to be able to register, pay their fare and choose their bus seats through the Internet. The problem I had was how to let the users complete their transactions quickly over the Internet, as they fill out the forms of the different pages.

So I went to the Internet to find an article or tutorial with the solution to the problem; this was in 2005. That was when I discovered Vlad’s articles and his web site. Later, I started thinking about Active Client Pages and how they can be improved. I discovered Chuck’s approach in 2007.

This Article

In this article I present my modified version of Chuck’s approach. I call the modification The Ajax Approach, not the Modified Chuck’s Approach. So, I will give you the Ajax Approach instead of Chuck’s approach. I will also give you my enhancements to this approach. You can learn more about Chuck and his work using the following links:


http://www.warrocketajax.com/?p=6

http://www.warrocketajax.com/?p=7

http://www.warrocketajax.com/index.php?s=active+client+pages&sbutt=Go


{mospagebreak title=Active Server Pages and Active Client Pages}

Many professional web sites use server-side applications like PHP, ASP, JSP etc. to generate their pages. All of these systems produce HTML pages at the server, based on data (or some non-standard information) at the server. Active Client Pages, on the other hand, produce HTML pages in the browser at the client, but still use data or information stored at the server. Well, with Active Client Pages, the very first page may be produced at the server. In practice, the rest of the pages, which are produced at the client, are actually downloaded from the server in advance as texts (strings with escaped entities).

Definition of Active Client Pages

We’ve read enough of a preamble to understand the definition of Active Client Pages. The definition I am giving you here is my definition. It is not what Vlad or Chuck has given. Active Client Pages are defined as the production of HTML pages at the client computer by the browser using web technology.

The data or information for the HTML pages reside at the server. You need a client script language, such as JavaScript, to produce the HTML pages at the client. I use JavaScript in my articles. I will write many articles using ACP. Let me now welcome you to the exciting world of Active Client Pages.

{mospagebreak title=Advantages of Active Client Pages}

Any information stored at the server, and its analysis, can be presented quickly to the user using ACP, independent of whether the Internet connection is fast or slow. Only the first page may take some time to be downloaded through a slow Internet connection.

Web pages are becoming voluminous because authors are putting a lot of script into them. This leads to slow download time. With ACP, the download time will no longer be slow, because the page will be downloaded in bits; only the first bit may take a long time.

If you understand your scripting language very well, you will pay less for hosting since the analysis will now be done by your script at the client and not by some program at the server.

ACP frees the server from work and so increases the overall speed of the World Wide Web. At the limit, if every client uses ACP, a client will not have to wait too long for the server to serve other clients before it is served, since the processing will be done at the client and not at the server; in other words, the server spends less time serving each client. One of the aims of N-Tier systems is to free the server from work. ACP also serves that purpose.

Secret of Active Client Pages

The secret of Active Client Pages is that, after the first page has been downloaded by the browser, other pages or data are downloaded in advance in the background, without the user knowing, and stored in an HTML master page (or frameset). This master page or frameset is the first page downloaded. By the time the user has finished reading and dealing with the first page, the information for the next few pages has arrived at the browser. When the user needs the next page, the browser displays it from the store (master page).

The Ajax Approach

I will not present Chuck’s approach as he did in his web pages. I present a modified form of it, which I call The Ajax Approach. I came up with this modification because I had to take into consideration the advantages mentioned above. Another discoverer of ACP is Vlad (see above). I have to mention that Vlad discovered his method before Ajax was invented. However, Vlad and Chuck’s philosophies are the same.

My philosophy is also the same. I have my own approach, on which I will write a series later. I had my inspiration from the works of Vlad and Chuck. My approach combines Vlad’s and Chuck’s works with a lot of my additions. But now, let us continue with the Ajax Approach.

{mospagebreak title=Ajax Features to Use}

Very quickly, then, what is Ajax?

  • AJAX stands for Asynchronous JavaScript And XML.

  • AJAX is a type of programming made popular in 2005 by Google (with Google Suggest).

  • AJAX is not a new programming language, but a new way to use existing standards.

  • With AJAX you can create better, faster, and more user-friendly web applications.

  • AJAX is based on JavaScript and HTTP requests.

In short, AJAX is not a new programming language, but a technique for creating better, faster, and more interactive web applications.

With AJAX, your JavaScript can communicate directly with the server, using the JavaScript XMLHttpRequest object. With this object, your JavaScript can trade data with a web server, without reloading the page.

AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.

The AJAX technique makes Internet applications smaller, faster and more user-friendly. AJAX is a browser technology independent of web server software. AJAX is based on the following web standards:

  • JavaScript

  • XML

  • HTML

  • CSS

The web standards used in AJAX are well defined, and supported by all major browsers. AJAX applications are browser- and platform-independent.

Web applications have many benefits over desktop applications; they can reach a larger audience, they are easier to install and support, and easier to develop. However, Internet applications are not always as "rich" and user-friendly as traditional desktop applications. With AJAX, Internet applications can be made richer and more user-friendly.

AJAX Http Requests

In traditional JavaScript coding, if you want to get any information from a database or a file on the server, or send user information to a server, you have to make an HTML form and GET or POST data to the server. The user will have to click the "Submit" button to send/get the information, wait for the server to respond, and then a new page will load with the results.

Because the server returns a new page each time the user submits input, traditional web applications can run slowly and tend to be less user-friendly.

With AJAX, your JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object.

With an HTTP request, a web page can make a request to, and get a response from, a web server — without reloading the page. The user will stay on the same page, and he or she will not notice that scripts request pages, or send data to a server in the background.

I have given you a lot for this part of the series. Let us take a break and continue in the next part of the series.

[gp-comments width="770" linklove="off" ]

antalya escort bayan antalya escort bayan Antalya escort diyarbakir escort