Javascript is not ajax

I see a lot of person talking about how ajax is cool and it helps you doing things that you couldn’t do before it was “invented”. What most of these people don’t know is that most of the coolest features are not ajax. Ajax is just a way to communicate between a client and a server without reloading the whole page. The rest of it is javascript, DHtml (dynamic Html) and CSS (cascading style-sheet).

Ajax forces javascript

Most people hate javascript but they want to do ajax, this is a duality. How do they overcome that problem? By using tons of javascript library and copying javascript snippets from tons of different sites. You know what? That won’t be any help for having well structured javascript. You just have to take javascript as seriously as your server-side language.

The structure

I saw a lot of web applications that were (almost) well documented. The developers spent hours thinking about doing a framework (argh!) that would help him handle all the code he will one day try to write. They didn’t have any thought about how they would write the javascript that will handle all that shit. “It will just flow” they say. No. I won’t “just flow”. It will be a mess.

Think about the javascript you’ll have to write and treat it with respect.

DHtml???

Once again, people do not make any difference between ajax and DHtml. When something in a page moves, it’s ajax. No, it’s DHtml. Ajax is just the response from the server that triggered the moving request. With DHtml, you can dynamically change the Html of your page using Javascript/DHtml (hey, I’m not talking about the innerHTML property). That’s where the javascript librairies (like jquery, script.aculo.us or mochikit) will help because the basic DHtml offered by javascript (with the DOM) is a real pain in the ass.

And CSS???

I also wrote Do not use the style property on HTML objects. That’s where CSS enters the battle.

Commentaires

  1. jdanylko April 13 2007 at 12:23:55

    Good post!

    I posted something similar where a user and developer were talking to me about enabling AJAX on a website.

    The functionality they wanted didn’t even require any server request at all…it was strictly modifying data on the screen (DHTML). The case here was that both of them probably heard the buzzword AJAX and wanted to implement on their website. I commend them on doing their homework, but in my eyes, they didn’t even finish their assignment. :-)
    I posted the story here: http://www.dcs-media.com/webx0/Detail.aspx?ArticleId=457

    Again…good post.

    JD

  2. Jim Plush April 15 2007 at 12:40:17

    ajax is the new dhtml

  3. Frank April 15 2007 at 15:08:24

    No it isn’t. AJAX is only a way for a web page to communicate with a server without refreshing itself. It has nothing to do with DOM or client side animation.

  4. Jim Plush April 15 2007 at 21:03:48

    frank, learn to read a joke. good lord.

  5. Frank April 15 2007 at 21:18:25

    oops. Sorry

  6. Dan (maintainer of Javascript Kata) April 16 2007 at 08:49:01

    It’s sad that a couple of months after jdanylko (first commenter), I have to do an article on the same subject. It proves that it is still not understood even if ajax is becoming older.

    @Jim : I really like the “ajax is the new dhtml”. It should have been my article title.

  7. Ganeshji Marwaha April 16 2007 at 13:30:41

    Dan,

    I completely agree that javascript is not ajax. I also agree that dhtml is not ajax. But at the same time i don’t agree that ajax is just the client-server communication. Ajax is a combination of client-server communication, dhtml and css to perform actions and display responses without page refreshes.

    It is wrong to say that dhtml is ajax, but it is equally wrong to say that ajax is just xmlhttprequest.

  8. Dan (maintainer of Javascript Kata) April 16 2007 at 13:37:53

    Ganeshji, you’re right. Ajax is a combination of technologies but ajax is NOT a technology in itself. That’s what I meant.

  9. BK April 17 2007 at 11:52:56

    simply said, AJAX is another buzz-word created to define something that existed for a long time but wasn’t “marketable”

Post a comment

Comments are moderated and innapropriate ones won't be approved. Please respect this public space.