Saturday, February 10, 2007

AJAX Thoughts from Greg

This is the link (http://www.gregextreme.com/tech/ajax.aspx ) from Greg's website for AJAX Thoughts of himself ,some standpoint is so correct and some example from our project .

AJAX, previously know as a household cleaner, now is a quite common term used for web sites. We won't go into what AJAX is or the basic implementation. This is covered in multitues of articles online already. What I want to point out are ideas for smart implementation and browser compatibility. I have seen some poor implementations from so called "professional" programmers. Not saying that my ideas and/or code are perfect, I'm sure they could be better, but they have been tested to show support for common browsers such as IE6+, Firefox 0.8+, Netscape 7.0+ and Safari for Mac. They should also work for Opera 6.0+ and possibly other browsers.(Because some parts is very old ,so there are many poor implementations on our SIF project about AJAX ,Old version just support IE only ,but new version we have tested on FF and IE.)
Use AJAX when appropriate, not for everything. This may seem obvious, but I have seen people go AJAX crazy which instead of making for a more pleasurable web experience, degrades it. Let's take an example, we have a server side web page which has dynamic links based on the user's rights and two select lists also with dynamic list contents based on their rights. The web page loads, then multiple synchronous AJAX requests are sent to the web server to set up the initial web page data. This includes which links are available to the user, the items available in the select lists, even the rights the user has on the page.(The example from our project , This is the problem from SIF and Tracker. we have to spend some time to update it right now and i have to admit that crazy man is me )

In this scenario, AJAX has done absolutely nothing to improve the web experience, it has actually degraded it. Instead of waiting for the server to process a web page and send it to the client (this includes server processing for rights determination, rendering the correct links on the page and rendering the dynamic select lists) with a single request to the server, now five web requests have to be made to the server. In a LAN environment, this may be acceptable since latency is not much concern, but over a WAN connection, the combined latency for multiple web requests can become unnecessarily slow.(well, I found the problem at the same time and http://www.cbf107.com also happened the problem .I need spend more time for think the server and the client, sometime i put too much requests on client )

One touted benefit of AJAX is transferring some load from the server to the client, but in this situation the server still needs to do about the same amount of work, if not more. It still needs to process rights determination, determine the correct links for the user and determine the correct items for the select lists. The only things it doesn't have to perform is the rendering of the web page to reflect the dynamic content, however this should surely be counteracted by the lookup and processing of session information which will be required for each AJAX request.

So the moral of Part I is that for any data that the page will display which is static for the user should be loaded directly into the page, not be gotten from subsequent AJAX requests. Notice the key, "static for the user". This means the content itself can still by dynamic, but if it does not need to be changed while the user is viewing the page, it is most likely best rendered by the server.( That view is so correct,but we didn't find before )

Anyway i need spend more time for think about the client side and maybe we need reconstruction some parts.

0 comments: