AJAX..Is It hype?
AJAX (Asynchronous Javascript And XML) seems to be a term that everyone is talking about. One person says it is hype, another person says it is the Holy Grail, and then you got the third person that says I have been using that for years. So is it hype? Is it new or old? What did people do before AJAX? Before I answer any of those, lets start from the point of having no clue about AJAX
What is AJAX and what can it do?
I have seen this question asked multiple times on the HTML and JavaScript forum here at http://www.JavaRanch.com and countless other forums. The simple answer is a programming concept that takes advantage of JavaScript’s XMLHttpRequest object to transfer information to and from the server without having to physically submit an entire page back to the server.
The cool thing about this is it works with JSP, ASP, .NET, PHP, etc. Are there any downfalls to note? Right off the bat, as always we need to rely on JavaScript. So for those users that are scared to death about JavaScript, since it is evil, they will not be able to handle this technology. Also, not all browsers handle the XMLHttpRequest Object. IE uses and ActiveX control and Mozilla followed IE (Yes they copied IE ~ surprised?) and implemented their own version of it. So that means wonderful cross browser code! So if your user is not using a current version of a browser, they will not be able to use this.
The second downfall is my favorite and why certain people call AJAX hype. That downfall is developer’s fear, ignorance, or hatred of JavaScript. I have been programming in JavaScript for over 10 years so I know it can be a pain. I have taught people how to program and I can still hear them banging their heads. People are afraid of this language since it has cross-browser differences. I wrote a book on JavaScript and I still have to sit there and bang my head when I forget which browser uses what for the width of the browser. It can be annoying, but grab a good reference and learn. Take a class, hire me (in the DC/Baltimore area), or buy a book!
Is this new? The term for AJAX is new but it has been around. IE implemented it years ago and no one seemed to use it. Then when the big names in the industry started to use it, people noticed its potential and went crazy. The way people jumped on this topic gave it the hype term, but over time I have seen so many applications utilizing the power of AJAX, that it is not hype and it is here to stay. Tell me that Google Maps, Google Suggest, GMAIL, or A9 is useless and is not user friendly.
With Ajax we can take a Web site’s user interface and turn it into a very rich client with responsiveness that reminds you of working with a desktop application. Yes we need to take into account network lag, but it is a lot quicker then rendering a page that has tons of images and HTML over and over again. For example, scroll the map on Google and scroll a map on MapQuest. Does that Network lag on Google compare to the post back and re-rendering of MapQuest? I will let you be the judge there.
The concept of avoiding post backs has been around for a long time. People have used this idea with hidden frames, iframes, and pop up windows for years. I have sent data back to the server through hidden iframes to keep people from being logged out of a web application. I have posted scores through an iframe for my JavaScript card games. I have seen pop ups used to transfer data to the server so the main page stays static so the user does not lose data. As you can see the concept has been there and we can improve.
The pop ups and frames have issues that the XMLHttpRequest object can address. My applications would freeze if there were 500 errors with pages. With the XMLHttpRequest Object, it is able to detect the 500 error and handle the situation. No more freezing.
In future articles I will discuss how to use the XMLHttpRequest Object, what are common mistakes I see, and what can we do to improve. So check back so you can learn more about AJAX and how it can help you create a Rich User Interface to improve your users experience.
As of right now, I am working with Dave Crane to produce AJAX In Action with Manning. That is the one main reason why my blog has been lacking material since I have been spending my free time creating content to give you the tools to unlock AJAX’s power. With the content in this book, we will give you the key to create the next AJAX application that everyone will be talking about! As it gets closer to publication I will talk more about the book.
Now please do not forget to check back and look for my next article on AJAX. If you have any questions about AJAX or JavaScript, add a comment here on my blog and I will make sure to answer it.
Eric Pascarello
Moderator of HTML/JavaScript at www.JavaRanch.com
Author of: JavaScript: Your Visual Blueprint for Dynamic Web Pages
my new articles I am going to post today an tomorrow is going to answer these questions hopefully.
Marilyn,
How hard is it to implement:
It is two JavaScript functions and a server side page to handle the request. Not that much work and I will show a basic example on Firday.
Would it be worth while if you only need to use it once in a project?
I would say yes. With the topic I am going to post today I discuss that using it too much many be bad. The tricky part is trying to figure out how to implement it your first time. After that you will be able to use it on multiple projects!
Eric
See the apply comment above!
Eric
Eric
Eric
> The only thing that you get from the XMLHttpRequest object is confirmation of completion unlike iframes, frames, and pop up windows.
Mmm, why so? I may be missing something, since i still have to look at the ASP.NET 2.0 implementation of the AJAX, but what about the onload event associated with all "loadable" objects? Also, a framed page can write back anything, scripts included, so that you have full control over the application logic. Well, at least in my own experience, i could always do what i needed.
Could you give any counter example?
Thanks for your attention. -LV
It seems that AJAX (Asynchronous Javascript And XML) has gained an extensive momentum since Jesse James Garrett from Adaptive...
Read more...