So How Do You Code an AJAX Web Page?
PetManimal writes "Computerworld has a long excerpt from a book by Edmond Woychowsky about how to code Web pages in AJAX. It gives a good explanation of how the technology works, and also has some visuals and code snippets that you can play with. From the article: 'Beyond the XMLHTTP Request object, which has been around for several years as a solution looking for a problem, there is nothing weird needed. Basically, it is how the individual pieces are put together. When they're put together in one way, it is nothing more than a pile of parts; however, when put together in another way, the monster essentially rises from its slab.'"
Beyond the XMLHTTP Request object, which has been around for several years as a solution looking for a problem, there is nothing weird needed. Basically, it is how the individual pieces are put together. When they're put together in one way, it is nothing more than a pile of parts; however, when put together in another way, the monster essentially rises from its slab.
But more importantly, one needs to remember that the internet is not a big truck, that you can dump information on. It's a series of tubes.
The theory of relativity doesn't work right in Arkansas.
1. Open Visual Studio
2. Download and install the ATLAS framework
3. Wrap your webpage in an update panel
4. Add a script manager
5. Lather, rinse, and repeat
Seriously...one drag-and-drop and you'll never see another page refresh.
Instead of wading thru 7+ pages of clicking and ads ... Printer Friendly version. You can thank me later.
Woychowsky repeats himself a lot. What's more, he says the same things over and over. In other words, he'll say something, and then re-phrase it with almost exactly the same words.
As I've mentioned, he seems to keep repeating himself
title So how (i) do (/i) you code an AJAX Web page? /title
:))))))
Haha, i mean, start ptocessing XML like this with Java and we will have a lot of browsers falling on their asses with exceptions
OK I am cruel!
I can see both sides of the argument, but do you really want a two-way connection through your browser?
When I have a kid, I want to put him in one of those strollers for twins and then run around the mall looking frantic.
How do I save an AJAX page in a given state, rather than just a state that will be "rebooted" on reload from storage?
--
make install -not war
Print version here.
Zero credibility points for trying to put markup in the <title> element and hiding the printable version behind a javascript:void(0) link.
If you want the technical stuff, skip about a third of the way down. The first third of the article just repeatedly tells you that Ajax is when the page doesn't "blink".
The code he supplies is crap. For instance:
Things wrong with even this tiny snippet of code:
Skimming the rest of the article, I see the following mistakes:
If this is a representative sample of the book it is excerpted from, steer well clear of it. The whole approach is poor.
The best way of producing compatible, accessible Ajax applications is to start with the bare HTML and make that work. Only then do you add the JavaScript, and you do it by enhancing the page, not replacing it. For instance, don't use <button onclick="...">, use a normal <input type="submit"> and hook into the form's submit event. That way:
Bogtha Bogtha Bogtha
The article is very verbose. It has some value, I suppose - it helped me to decide I didn't want to buy the book. There are more concise introductions to Ajax here and here
There is also an interesting library of Javascript/ECMAscript functions to perform common Ajax chores here
1. Download Echo2 http://nextapp.com/platform/echo2/echo/
2. Write AJAX applications like you would a Swing app, never touching HTML or Javascript.
3. Go outside and play.
'nuff said.
Yes, there are ugly hacks to keep a connection alive, but it is exactly that, a hack, and introduces problems of it's own.
There are some ugly hacks to allow the server to "push" to the client (embedded flash objects, never-closed-connections, etc.)--mostly encapsulated by the moniker COMET (get it? Ajax... Comet...)
But if you get to pick your app server, there are some ready-made solutions. The problem with traditional web servers is their IO method. It's not their fault that the HTTP spec is out-of-date, but there are already new developments on the horizon that get around the current limitations. Take a look at GlassFish, Sun's new open-source enterprise application server, and pay particular attention to NIO socket writes. The performance benefits of NIO over straight IO are astonishing, with the side-benefit that it supports server-push out-of-the-box.
Comment removed based on user account deletion
Nobody calls XmlHttpRequest() directly anymore. It's too much work, and there are slight differences between browser implementations. Nowadays everyone is using a wrapper library. Prototype is a very common one (it's certainly my favorite) -- abstracts everything into a nice set of functions for you -- you just specify the HTTP call you want to make, and the function you want it to call when the data comes back (because, in case you're not already aware, XmlHttpRequest() returns its data asynchronously).
The other nice thing you can do with Prototype is to avoid XML parsing altogether by saying "ok, here's the URL I want you to call; it's going to return pre-rendered HTML, and when it does, I want you to stick it in this DIV over here; don't bother me about it" and you can do things like automatically update portions of your page without reloading. You can even have an automatically recurring update, which is very cool for things like tickers, clocks, etc. We used it in our AJAX webmail/calendar system and it really worked well.
Tired of FB/Google censorship? Visit UNCENSORED!
Bandwidth ain't _that_ cheap. A constant connection would be annoying to maintain in spotting wifi, electrical storms, etc.
I personally prefer web development because of the forced finite life of each state. That sort of back and forth makes data validation, cross-process security, and other things that many web developers ignore very easy to implement. You just have to quit thinking continuously (rimshot please!) and start thinking discretely.
When I have a kid, I want to put him in one of those strollers for twins and then run around the mall looking frantic.
Really? Then why doesn't it say "+5 Funny" on my shirt?
This space intentionally left (almost) blank.
Why doesn't Slashdot implement it? This would be especially nice for expanding/collapsing in the discussions.
We're all hypocrites. We all have hidden parts, it's the contrast between them that make us more a hypocrite than others
I recently published my first Ajax application. It is an online game called Grand Strategy, a close of the well known board game Risk.
It is by far the most advanced Ajax based implementation of a board game to have ever been written!
I used Direct Web Remoting (DWR) and the Dojo Toolkit. My javascript talks to my server side java beans directly. It's really the easiest web programming model I have ever seen. I hurts to go back to doing ASPX and PHP pages after this.
Check it out here:
http://denizengames.com/grandstrategy/
Command line interfaces are for n00bs. I use a magnet to change each byte on my hard drive.
Stupidity is like nuclear power, it can be used for good or evil. And you don't want to get any on you.