Slashdot Mirror


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.'"

8 of 231 comments (clear)

  1. finishing the thought... by User+956 · · Score: 5, Funny

    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.
  2. So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 5, Informative

    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.

  3. Both Repetitive and Redundant by Stringer+Bell · · Score: 5, Funny

    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

  4. Huh by Bogtha · · Score: 5, Insightful

    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:

    <html> <head>

    <title>HTMLfs</title>
    </head>
    <framese t rows="100%,*">
    <frame name="visible_frame" src="visible.htm">
    <frame name="hidden_frame" src="hidden.htm">
    <noframes>Frames are required to use this Web site.</noframes>

    Things wrong with even this tiny snippet of code:

    • Invalid.
    • Frames (at the very least, he should have used iframes).
    • Cheesy "fuck off" error message instead of functional equivalent.

    Skimming the rest of the article, I see the following mistakes:

    • Using DOM methods without testing for their existence.
    • Browser detection (which is stupid and wrong).
    • Obtrusive JavaScript embedded in the page with old-fashioned HTML attributes.
    • Non-degradable JavaScript form submission with <button> instead of <submit>.
    • Confusion over what elements and tags are.
    • Internet Explorer-only code without error checking or a fallback.

    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:

    • It works when JavaScript is unavailable.
    • It works when there's a problem in your code.
    • It works when you find you can't do something halfway through processing the event (e.g. you find that ActiveX is switched off in Internet Explorer, making XMLHttpRequest unavailable).
    --
    Bogtha Bogtha Bogtha
  5. There are much better intros to Ajax by njdj · · Score: 5, Informative

    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

  6. Oh yeah? by The_REAL_DZA · · Score: 5, Funny
    AJAX is a joke

    Slashdot is a joke

    You are a joke

    Really? Then why doesn't it say "+5 Funny" on my shirt?
    --


    This space intentionally left (almost) blank.
  7. Speaking of AJAX... by Chabil+Ha' · · Score: 5, Interesting

    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
    1. Re:Speaking of AJAX... by spencer1 · · Score: 5, Informative

      Slashdot is currently testing just that among a small group over users. http://slashdot.org/faq/com-mod.shtml#cm120