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

231 comments

  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.
    1. Re:finishing the thought... by __aaclcg7560 · · Score: 2, Interesting

      It's a series of tubes.

      You got it all wrong about the tubes, my friend. :P

    2. Re:finishing the thought... by Anonymous Coward · · Score: 0
      Ten of them streaming across that internet and what happens to your own personal internet?

      I just the other day got, an internet was sent by my staff at 10 o'clock in the morning on Friday and I just got it yesterday. Why?

      Because it got tangled up with all these things going on the internet commercially.

      So you want to talk about the consumer? Let's talk about you and me. We use this internet to communicate and we aren't using it for commercial purposes.

      Maybe there is a place for a commercial net but it's not using what consumers use every day.

      It's not using the messaging service that is essential to small businesses, to our operation of families.

      Senator Ted Stevens (R-Alaska)



      This guy's an idiot.

      Small businesses are not commercial?

      My job as a web developer isn't using the tubes commercially?

      I don't BUY things from large corporations over the tubes?

      Do we only elect certifiable lunatics and barely-functional morons into office anymore?

    3. Re:finishing the thought... by Anonymous Coward · · Score: 0

      Q: So How Do You Code an AJAX Web Page?

      A: You don't. If you want your page to be viewable regardless of the users browser settings you will code it to output compliant html only.

      Javascript still sucks and is a totally retarded idea.

  2. Well, first things first... by The_REAL_DZA · · Score: 0

    First, you click [Start][Programs][Accessories][Notepad]...

    --


    This space intentionally left (almost) blank.
    1. Re:Well, first things first... by khendron · · Score: 1

      Maybe *you* do, but I click [Applications][Accessories][Text Editor].

      --
      Life is like a web application. Sometime you need cookies just to get by.
    2. Re:Well, first things first... by dpreston · · Score: 2, Funny

      Try...

      $ vi <enter>

    3. Re:Well, first things first... by Anonymous Coward · · Score: 0

      just so long as you don't use one of them fancy pants html editors or wysiwyg thingies.

      I think that was what he was going for too
      REAL page building is done with a barebones text editor and nothing else.

    4. Re:Well, first things first... by vhogemann · · Score: 1

      apt-get install vim

      --
      ---- You know how some doctors have the Messiah complex - they need to save the world? You've got the "Rubik's" complex
    5. Re:Well, first things first... by setirw · · Score: 1

      You newfangled whippersnappers! I do: $ ed

      --
      This message printed on 100% post-consumer recycled electrons.
    6. Re:Well, first things first... by Bill+Dog · · Score: 1
      Editors are for losers who make mistakes.
       
      C:\Documents and Settings\lua>copy con: ajaxrulez.html
      <!-- what do I do next??? -->
      ^Z
              1 file(s) copied.
       
      C:\Documents and Settings\lua>
      --
      Attention zealots and haters: 00100 00100
    7. Re:Well, first things first... by The_Wilschon · · Score: 1

      $ vi
      bash: syntax error near unexpected token `newline'

      --
      SIGSEGV caught, terminating

      wait... not that kind of sig.
    8. Re:Well, first things first... by Millenniumman · · Score: 3, Funny

      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.
    9. Re:Well, first things first... by Anonymous Coward · · Score: 0
    10. Re:Well, first things first... by Lars83 · · Score: 1

      I use a magnet to change each bit!

  3. 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.

    1. Re:So How Do You Code an AJAX Web Page? by Chunt620 · · Score: 3, Funny

      That is correct. 10 minutes of work and you too can name your site wixi, plexxy, swiggle, gippy.......[insert "trendy" web 2.0 names here]

    2. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 0

      Replace "So How Do You Code an AJAX Web Page?" with "So How Do You Code an AJAX Web Page for IE only?" and your comment is correct.

    3. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 3, Informative
      Replace "So How Do You Code an AJAX Web Page?" with "So How Do You Code an AJAX Web Page for IE only?" and your comment is correct.
      ATLAS is a cross-browser AJAX framework, and Visual Studio 2005 produces valid, meaningful XHTML.

      Nice troll, though.
    4. Re:So How Do You Code an AJAX Web Page? by vux984 · · Score: 3, Informative

      /shrug

      Visual Studio actually has a pretty solid source code editor, with good syntax highlighting, and its code completion for css properties and html attributes is very good. (And its ability to offer effortless code completion for asp tags, AND user-defined controls is extremely helpful.) Not to mention its real-time "error" checking (improper tag nesting, mismatched tags, etc). It prevents and catches a lot of potential errors as you make them.

      I do agree that doing a lot of work in the gui-designer results in bloated pages that need a ton of work to slim down and make crossplatform friendly. But nobody is forcing you to do that, and really if you know what you are doing you almost never use the visual designer mode. I only use it to drag user-controls onto the page; because in gui-mode it handles the boilerplate to register the tagprefix, etc. I also occasionally use it to create event handlers, because double clicking say a linkbutton in design view will write the boilerplate for the function signature, as well as handle the event wiring.

      Like any tool, Visual Studio can be used effectively or ineffectively. When compared to most other "light tools" I find Visual Studio to be more productive -- sure I can build pages even in notepad but I make fewer typos when using the source code editor in Visual studio.

      (There are other good editors too, don't get me wrong. I'm just saying that visual studio belongs among them.)

    5. Re:So How Do You Code an AJAX Web Page? by Chunt620 · · Score: 2, Insightful

      Development using Visual Studio has little to do with being a man and alot to do with wanting to complete projects within a reasonable timeframe. As a former PHP-lifer turned Visual Studio lover, I can attest to the fact that Visual Studio WILL cut your time to release numbers significantly/

    6. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 4, Funny

      [insert "trendy" web 2.0 names here]

      shitty

    7. Re:So How Do You Code an AJAX Web Page? by naoursla · · Score: 2, Informative

      You forgot step zero: Download the free version of Visual Studio Express.

      And in the interest of full-disclosure, I recently started working for Microsoft on Visual Studio features directly related to AJAX and ATLAS. So now this post is just ordinary spam instead of a sneaky shill.

    8. Re:So How Do You Code an AJAX Web Page? by CastrTroy · · Score: 3, Interesting

      Light Tools? What are you talking about. My current copy of Visual Studio is eating up 290 Megs for RAM. I will go with you on your opinion though. VS.Net is a great tool, and probably one of the best editors I've ever seen. The bad part is that it's hidden behind the drag and drop interface that it presents. MS tools get you to focus on the GUI, and don't make you get underneath to understand what's going on. This leads to a lot of programmers who can get their way around VS easily enough, and even write some good programs, but as soon as they need to do something that visual studio didn't expect, they have a really hard time.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    9. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 0

      Your website sucks. The download link is hidden away, the pictures are totally fucking lame, the UI is inconsistent.

    10. Re:So How Do You Code an AJAX Web Page? by vux984 · · Score: 1

      Light Tools? What are you talking about?

      The parent to my post said "REal men still code in a simple code tool. Fakers and wannabees use Visual studio."

      I was specifically comparing VS to -other- light tools that would fall under the "simple code tool" that the GP is apparently so fond of.

      I agree, VS is not a light tool itself. :)

    11. Re:So How Do You Code an AJAX Web Page? by multimediavt · · Score: 1

      Amen. And real men call it XML, JavaScript, and HTML, not AJAX. I heard that term for the first time about six months ago and laughed my ass off when I found out what it was. I thought it was something new, not something old (that most web developers have been doing for at least three or four years now) given some new name to make it sound cool to people who could only remember one name instead of three. I think AJAX is a cleaning product, and somebody used it to describe what they do to dupe someone else into giving them a job. Either that, or some stupid HR person made it up!

    12. Re:So How Do You Code an AJAX Web Page? by Anamanaman · · Score: 3, Funny

      Shhhhhhhhh

      I have everyone convinced I'm a leet AJAX programmer after I dragged in a single UpdatePanel on my company's internal web app.

      You're going to ruin it for everyone. Keep quiet!

    13. Re:So How Do You Code an AJAX Web Page? by tonyr1988 · · Score: 1, Funny

      6. ???
      7. Profit!

    14. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 0

      "So How Do You Code an AJAX Web Page?"

      You don't. Because it cannot be guaranteed to work no matter what you do. As a developer you have no control over a users browser security settings and simply cannot use technology that the user can disable (whether they are aware they have or not).

      If you want a webpage that does not work reliably, sure go ahead, use javascript, but I cannot imagine why anyone would want that.

    15. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 0

      Oh yeah? Well your momma wears combat boots when she goes to bed with me.

    16. Re:So How Do You Code an AJAX Web Page? by naoursla · · Score: 4, Informative

      I would never describe myself as a graphic artist so I will neither agree nor disagree with you.

      However, for the web impaired here is a direct link for the web developer version only (which you can get to by clicking the big download picture on the right hand side of each product specific page and then clicking "Download" in step 2).

      And as long as I am providing overly simple instructions to trolls, I guess I'll point out that ATLAS does not come installed with Visual Studio. You have to download it from atlas.asp.net (hint: there is a big download icon at the top of the screen).

      And if you would like a demo of how easy it is to create ajax applications with atlas, there is current a video on the front page of someone creating a database backed todo-list application in 18 minutes (the express version of Visual Studio comes with a lightweight database and web server for development. I think you can probably repeat this demo with the free tools).

    17. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 0

      Apart from Visual Studio, which I'm hardly looking forward to install, is there a specialized IDE for JavaScript? Not just a syntax highlighting and code completion editor - something as powerfull like Zend or PHPedit for PHP, or maybe Eclipse for Java?

      Can be commercial, I don't mind paying for tools that do the job.

    18. Re:So How Do You Code an AJAX Web Page? by Heembo · · Score: 0, Troll

      I'm still using secureCRT to get to a unix prompt, then I use VI or EMACS to code everything by hand using solid reusable libraries. Doesn't anyone do that anymore? I've done much of photos.sun.com that way, ajax and all. Am I crazy?

      --
      Horns are really just a broken halo.
    19. Re:So How Do You Code an AJAX Web Page? by drew · · Score: 1

      6. Gasp at your bandwidth bills when you realize that you had to include an 84k JS file for a simple "hello world" application.
      7. Spend hours trying to figure out why any custom script files you want to include in your head element once you try to do something non-trivial mysteriously aren't working.

      --
      If I don't put anything here, will anyone recognize me anymore?
    20. Re:So How Do You Code an AJAX Web Page? by __aaclcg7560 · · Score: 1

      That's why I think it's conspiracy to rename old technology to sell overpriced books covering the "newest" technology that ain't so new much less hot. I stopped buying door stoppers unless I really need the book and there's a significant sales discount being offered.

    21. Re:So How Do You Code an AJAX Web Page? by Zardoz44 · · Score: 1
      Anon, but I'll still bite since I rarely hear this mentioned:

      Visual Studio is a better debugger than Venkman. Start debugging, attach to IE, script type, and start stepping through. Sure you can use the MS Script debugger as well, but there's other good things about Visual Studio for .js editing.

      Notepad variants are good for simple projects, but nothing beats coding in the same UI as your debugger. Especially if you're doing AJAX with a C++ back-end and use Visual Studio for that anyway.

    22. Re:So How Do You Code an AJAX Web Page? by misleb · · Score: 3, Funny
      It prevents and catches a lot of potential errors as you make them.


      Man, I hate it when I make potential errors. How does VS deal with virtual errors?

      -matthew
      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    23. Re:So How Do You Code an AJAX Web Page? by misleb · · Score: 1

      You tell em! I just heard the term "body modification" about the year ago. I just about laughed my ass off when I found out they were just talking about piercings and tatoos. I thought it was something new like cybernetic implants or something... not the same stuff most of my friends have been doing for years now. Sounds like they just gave it a fancy name to make it cool to people who could only remember one term instead of two. What tools.

      Oh yeah, and my slashdot ID is lower than yours. I was doing slashdot *before* it was popular. Nyah!

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    24. Re:So How Do You Code an AJAX Web Page? by vux984 · · Score: 1

      Man, I hate it when I make potential errors. How does VS deal with virtual errors?

      Potential errors = errors that could/would have happened but didn't.
      I'm not sure what your "virtual errors" would be.

      VS eliminates a lot of potential errors... for example: I often forget whether the spelling of the css 'built in color' is "grey" or "gray"; Iirc firefox accepts both, while IE only understands gray. My natural inclination is to spell 'grey', but the standard specifies 'gray'. VS code completion helps prevent me from using 'grey'.

      By popping up the list of colors as i type, the odds of me getting it wrong is reduced. And a potential error is avoided.

      Simililarly, it also helps ensure that the elements of a 'background:' are ordered correctly, as in some cases some browsers ignore them if they aren't in the right order.

      By showing me the syntax as I type, the potential for me to put them in the wrong order is greatly reduced. And a potential error is avoided.

      cheers

    25. Re:So How Do You Code an AJAX Web Page? by misleb · · Score: 0, Flamebait
      Potential errors = errors that could/would have happened but didn't.


      Apparently you missed the sarcasm. I should have used [tags]. My point was that if the error didn't happen (remained potential) you didn't make it. Otherwise they would be actual errors or real errors. In other words, "make a potential error" is an oxymoron.

      I thought I was being +1 funny. I'll probablly get modded -1 flaimbait. :-(

      -matthew
      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    26. Re:So How Do You Code an AJAX Web Page? by monoqlith · · Score: 1

      So you're going to forfeit your ability to use a pretty cool technology just because some users *might* have javascript disabled? What if you're in a corporate environment where you pretty much know none of your web application's users are going to modify their browser settings and you know what type of browsers they aer using? And while it is true that cross-browser compatibility is difficult and time-consuming to guarantee, other technologies like the Google Web Toolkit(which I am using right now to build an AJAX application entirely in Java for my university....well, while I'm not slacking off and reading slashdot, anyway) save a lot of that work.

    27. Re:So How Do You Code an AJAX Web Page? by funfail · · Score: 1

      I didn't try it yet but check this out:

      http://www.aptana.com/

    28. Re:So How Do You Code an AJAX Web Page? by Anonymous Coward · · Score: 0

      Given the condition of your bed, I'm not surprised.

    29. Re:So How Do You Code an AJAX Web Page? by grazzy · · Score: 1

      Sellout :p

    30. Re:So How Do You Code an AJAX Web Page? by Not+The+Real+Me · · Score: 2, Insightful

      "ATLAS is a cross-browser AJAX framework, and Visual Studio 2005 produces valid, meaningful XHTML."

      More important, will the final product run on a non-Microsoft web server?

    31. Re:So How Do You Code an AJAX Web Page? by C10H14N2 · · Score: 1

      The parent was clearly saying that extra weight is justified in this case in terms of increased productivity. Obviously, no one in their right mind would seriously imply that VS is in any way shape or form "light."

      Perhaps re-reading the statement as "compared to the other, lighter tools..." would clarify this.

    32. Re:So How Do You Code an AJAX Web Page? by fforw · · Score: 1
      1. Not all all js libs are that large. (shameless plug: my ff javascript library is below 7k)
      2. Use Javascript compression
      3. Use gzip compression / gzip precompression ( ff javascript libray shrinks to below 3kb )
      4. Use Firebug
      --
      while (!asleep()) sheep++
    33. Re:So How Do You Code an AJAX Web Page? by oyenstikker · · Score: 1

      My development environment consists of xterm, vim, ant, svn (subversion), grep, sed, and 3 web browsers (IE*, Firefox, and Konqueror) to test everything. (Okay, I simple graphical subversion client (esvn) and gvim too.)

      I have my ant build scripts set up such that I can compile and deloy any of many configurations simply by passing an argument to ant, or any of many branches of the code by changing directories and rerunning ant. These tasks take my coworkers several minutes at best, as they have to change configurations in their IDEs (Eclipse and JBuilder) and manually move some directories around. They ask me every day if I can print a change log (svn log | lpr), or grep for something, or test a changeset on a different branch. (But they still ask me every day why I don't use an IDE.)

      I will use an IDE if somebody makes one that has vi keybindings, vi style macros, some of the vi commands I use most (:s is most important), and keyboard text selection, copy and paste. It must also adapt to my directory setup and ant build files. It should be easy: parse the ant build file to get the source directory, the compiler output directory, and the required libraries. Then do all those cool editor tricks that I really wish I had, like right click on a method definition and find references. It would then need an icon for my build file that I could click to run the default target, or right click to get a flyout of its tasks. Then call ant. Add a file manager with cvs and subversion support, and you'd have a winner.

      *VMWare running Windows 2000, with Adobe Acrobat Pro and IE. All legit. (I was amazed at how supportive Adobe was with me running Acrobat on VMWare. They emailed me a patch (the same one for people with RAID drives I think) so it didn't always think I had changed hardware, and its been working great. One of the tech support people I talked to was a GNU/Linux user himself.)

      --
      The masses are the crack whores of religion.
    34. Re:So How Do You Code an AJAX Web Page? by oyenstikker · · Score: 1

      "So you're going to forfeit your ability to use a pretty cool technology just because some users *might* have javascript disabled?"

      If your users pay you, and get angry with you because their IT guy came in during the weekend and ran Windows Update, which changed their security settings, and now your site doesn't work anymore (takes 30 minutes on the phone to find out what happened), and its all your fault, and then they badmouth you when prospective customers call for references, then yes, you forfeit your ability to use pretty cool technology.

      --
      The masses are the crack whores of religion.
    35. Re:So How Do You Code an AJAX Web Page? by Heembo · · Score: 1

      You are my new god, I throw all my extra flash drives and at your feet and bow to your non-IDE uber enviornment!

      --
      Horns are really just a broken halo.
    36. Re:So How Do You Code an AJAX Web Page? by enk0 · · Score: 1

      or, more appropriately: shitty beta

    37. Re:So How Do You Code an AJAX Web Page? by jdbartlett · · Score: 1

      No, real men call it JSON, JavaScript, and XHTML. Or "Ajax". Either way is good. Ajax is much shorter, really. Sort of convenient in its own way.

    38. Re:So How Do You Code an AJAX Web Page? by drew · · Score: 1

      I was referring to ATLAS specifically, not AJAX in general. Almost all of my work is AJAX-style development, (although with libraries that my company has been developing in-house over the last 3+ years) so I know that it is certainly possible to create lightweight JavaScript libraries.

      ATLAS however, seems to offer very little to justify it's hefty download size. I misspoke in my original post- it's more like 55kB, but that's still ridiculously heavy for what seems to be mainly a wrapper for using xmlHttpRequest to make SOAP requests to a web service and hand the result to a JavaScript callback function, and breaks a whole lot of things in the process.

      A sysadmin I worked with long ago used to be fond of using the phrase "a solution in search of a problem", which seems to me to sum up ATLAS quite nicely.

      --
      If I don't put anything here, will anyone recognize me anymore?
  4. Printer Friendly by neonprimetime · · Score: 4, Informative

    Instead of wading thru 7+ pages of clicking and ads ... Printer Friendly version. You can thank me later.

    1. Re:Printer Friendly by Anonymous Coward · · Score: 0

      I was going to thank you now, but since I'm a procrastinator and you said so...

    2. Re:Printer Friendly by Anonymous Coward · · Score: 0

      Ok, here it comes:
      Thank you.

    3. Re:Printer Friendly by 6ULDV8 · · Score: 1

      Well, thank you, but if you do that, you miss http://www.computerworld.com/action/article.do?com mand=viewArticleBasic&articleId=9002206, which was unfortunately much more interesting than the intended article.

      --
      Pull my finger for my public key.
    4. Re:Printer Friendly by Ced_Ex · · Score: 1

      He said LATER!!!!

      --
      Live forever, or die trying.
  5. Single Page Coral Cache Version by mshmgi · · Score: 0
  6. I'd post my 20-line AJAX function... by The+MAZZTer · · Score: 1

    ...but slashdot keeps blocking it with a "lameness" filter, insisting it's "junk characters". Go figure, I didn't know slashdot was anti-web 2.0!

    1. Re:I'd post my 20-line AJAX function... by Anonymous Coward · · Score: 0

      web 2.0 != the code that runs web 2.0

    2. Re:I'd post my 20-line AJAX function... by DigitalRaptor · · Score: 2, Funny

      Slashdot isn't anti Web 2.0, it's dissing your code... calling it lame garbage.

      But don't take it personally.

      --
      Lose Weight and Feel Great with Isagenix
    3. Re:I'd post my 20-line AJAX function... by pete6677 · · Score: 1

      That's to block the ASCII goatse that used to be so common on this site. Those were the days...

  7. Careful of the scrubbing bubbles by Anonymous Coward · · Score: 0

    You need to watch what you mix with ajax because it can become lethal

  8. Re:FP by Anonymous Coward · · Score: 0

    The kids would love it

  9. HTTP, time to update? by not+already+in+use · · Score: 2, Interesting

    With the growing popularity of AJAX does anyone think it's time to update the HTTP spec? AJAX is cool tech but still hindered by the fact that the client has to initiate every request. Yes, there are ugly hacks to keep a connection alive, but it is exactly that, a hack, and introduces problems of it's own.

    --
    Similes are like metaphors
    1. Re:HTTP, time to update? by suggsjc · · Score: 3, Interesting

      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.
    2. Re:HTTP, time to update? by not+already+in+use · · Score: 2, Informative

      I assume you are indicating that it may be a security issue on the client side, but I don't see it allowing for any more malicious activity than there already is. The onLoad tag of the body element can fire up an XMLHTTPRequest that gets a response from the server automatically. This would be no different than the server polling the client if such a connection were possible. I think it would be more of a performance issue on the server end, having to host so many live connections.

      --
      Similes are like metaphors
    3. Re:HTTP, time to update? by Civil_Disobedient · · Score: 3, Informative

      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.

    4. Re:HTTP, time to update? by not+already+in+use · · Score: 1

      Wouldn't that force you to write your applications in Java? The beauty of ajax is being able to do so much with just an HTTP server, a server side scripting language, javascript and html.

      --
      Similes are like metaphors
    5. Re:HTTP, time to update? by Anonymous Coward · · Score: 0

      Of course you do. Think about it. You click on a link and your screen is filled with goatse. And you don't even have to do anything for it. That's rich client for you!

    6. Re:HTTP, time to update? by richdun · · Score: 4, Insightful

      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.

    7. Re:HTTP, time to update? by catbutt · · Score: 2, Interesting

      I think the more limiting issue is that it is so hard to do AJAX across domains. XMLHttpRequest doesn't work, nor do hidden iframes. I think no one has put too much thought into what the potential of this is if it could be done.

      However, they appear be building something at Ajaxlets.com that is supposedly a clean, open source solution to this, by packetizing the data in javascript script urls. Apparently their release is a few days off.

    8. Re:HTTP, time to update? by baadger · · Score: 2, Insightful

      Better question, do you really want to be at the server end of a slashdotting consisting of persistent connections?

    9. Re:HTTP, time to update? by suggsjc · · Score: 3, Insightful
      The real questions are:
      1. What do we want the web to be?
      2. What role will HTTP play in the answer to #1
      3. If the answer to #2 is fall by the wayside, then who is going to create its succesor?
      4. Then, after the answer to #3 is figured out...do you really want to be at the server end of that connection?
      --
      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.
    10. Re:HTTP, time to update? by Tiles · · Score: 1

      HTTP 1.0 already has keep-alive connections, and already has the capability to send requests, so there's no need to update the spec.

      What you're describing is making the server a client and turning the user's computer into a server, which has a number of implications. It's simply much more feasible for the user to pull content than the server to push it, especially as it leaves it up to the user's discretion when to receive updates.

    11. Re:HTTP, time to update? by God+of+Lemmings · · Score: 2, Insightful

      Hacks to keep a connection alive? Over TCP/IP, a connection based protocol?! No, really?!

      I am not certain that it is time to update the HTTP spec so much as to come up with an
      accompanying spec for connection based browser communication before microsoft does.

      Something similar to xmlHTTPrequest, but something that can maintain a symmetrical
      connection that HTTP is not designed for.

      I dunno, maybe something vaguely like this: (and i stress vaguely)

      <script type="text/javascript">
              var server = new host ("192.168.2.3");
              var state = "michigan";
              host.connect();
              host.send("query.php?capitalof="+state);
              document.write(" The capital of "+state+" is "+host.recv()+"<br>" );
              host.send("query.php?populationof="+state);
              document.write(" The population of "+state+" is "+host.recv()+"<br>" );
              host.close();
      </script>

      --
      Non sequitur: Your facts are uncoordinated.
    12. Re:HTTP, time to update? by ARWolff · · Score: 1

      Amen. Web servers are for discrete transactions, not IRC, MUDs or other, keep-alive applications. You want to do a constant-state, client-server thing? Then write a socket app.

      The advantage of Ajax (either XML or JSON via XHR) is reducing the size of each transaction, so you can pull in the little pieces of data you need without reloading a whole page. This is NOT the same thing as keep-alive.

    13. Re:HTTP, time to update? by Anonymous Coward · · Score: 0

      I remember playing around with http continuations in Netscape 3.x or 4.x a while ago... It was kind of cool you could use it to display cheesy animations and then I forgot about it but it can definately be used to push content from the server.. have it run in a hidden frame somewhere and your all set. Why is it that everytime I play with even simple ajax libraries after a while 'something' happens. The display gets mucked up, the browser window freezes, it goes haywire and spins the cpu or eats gobs of memory and or handles and when it doesen't do any of that it doesen't work with the other browser. Honestly once every 8-9 months for the past few years I'll put a days worth of effort into finding some useful libraries and then I'll give up on it do to the reliability problems. Also for many of the spaces I work in its more effecient to grab data from the server more often vs loading gobs of scripts and data all at once. Especially if you use technologies like CSS reloading the page is dirt cheap and writing some simple JS to mess with styles/dom always seem to work for me. At some point if you want an interactive app and you want it to chat with a server efficently ... why not just write a java applet?

    14. Re:HTTP, time to update? by Bogtha · · Score: 1

      I think the more limiting issue is that it is so hard to do AJAX across domains. XMLHttpRequest doesn't work, nor do hidden iframes.

      Not true - there's a trick to get around iframe cross-domain security. You can still see the URIs of the frame. This means that the domain you are attempting to access can supply a special page that calls XMLHttpRequest on your behalf and streams the data to you by updating the fragment identifier.

      It's an awful hack, but it's been wrapped up in an XMLHttpRequest emulation by Dojo.

      Looking further ahead, there's already a proper model for cross-domain communication, and Opera already supports it.

      --
      Bogtha Bogtha Bogtha
    15. Re:HTTP, time to update? by Civil_Disobedient · · Score: 1

      Wouldn't that force you to write your applications in Java? The beauty of ajax is being able to do so much with just an HTTP server, a server side scripting language, javascript and html.

      The beauty of AJAX is being able to communicate with the server without reloading the entire page.

      That's it.

      If you're talking about a non-polling push mechanism on your web server, I can just about guarantee you that the server powering it isn't going to be running friggin' PHP.

    16. Re:HTTP, time to update? by rbanffy · · Score: 1

      I would rather do:

      <script type="text/javascript">
                      capitalSpan = document.getElementById("capital");
                      populationSpan = document.getElementById("population");
                      var state = "Michigan";
                      var capital = httpGet("http://192.168.2.3/query.php?capitalOf=" + state, HTTP.TRYNOTTOCLOSEITRIGHTNOW);
                      capitalSpan.innerHTML= " The capital of " + state + " is "+ capital +"<br>";
                      var population = httpGet("http://192.168.2.3/query.php?capitalOf=" + state, HTTP.YOUMAYCLOSETHIS);
                      populationSpan.innerHTML = " The population of " + state + " is "+ population +"<br>";
      </script>

      I would rather let the infrastruture manage the connection lifespan and give it hints about what I intend to do.

      And, yes. Better if someone other than MS creates a de-facto standard.

    17. Re:HTTP, time to update? by budgenator · · Score: 1

      You don't want to do that because your servers TCP/IP stack only has about 60K useable ports(64K ports - WKS and a few others), and each connection uses a port, then most real web pages connect to a database which means your down to 30K connections, now add in a couple connections for RSS feeds and your down to under 8K connectionsnow consider slashdot with almost a million registered user and have it setup so that only a thousand or so could connect to the site! I know we could do some hacks at the routers, but they're still computers and still have a ~ 60K ceiling, no it's far better to use the non-persistant connections and recycle the port amongst the users as needed else connection refused and service unavailable would be the order of the day.

      --
      Apocalypse Cancelled, Sorry, No Ticket Refunds
    18. Re:HTTP, time to update? by budgenator · · Score: 1

      well yeah you'd be forced to use java, at least untill the perl modules appeared on CPAN to duplicate the technology in an open source language, Java is only almost open so the OSS purests will complain bitterly. Then of course there would be a re-implimentation into PHP and put up on PEAR which of course would be a bit half-assed so there have to be 3 half-assed PHP implimentations on PEAR just to cover the whole feature set, you can't have anything on CPAN and not have it on PEAR. Now the Python guys will get into the act because god knows you can't read or maintain Perl and PHP is just Perl on anti-psycotic medication so it's only schizophrenic half the time instead of all the time like Perl.
      While all of this is going on Microsoft is working furiously on an implimentation in C#/.net, and of course because they playing catch-up they gloss over a few things like security and stability, never mind that the marketing-driods are pimping vaporware at this point; all of the Novelites will tie a blond to the stakes and start chanting "MONO MONO" to the Monkey God. By now everything will be so fubared that and Sun will announce they're discontinuing developement so we will not even have just a java implimentation that works.

      No seriously, why is coding Apache in C, writing the server-side in java, Perl or PHP, sending everything to the browser that's coded in C, A language called HTML with the languages of javascript, Java and Flash embedded into it and the browser is almost guarenteed to manged your code any more difficult than just using java in a client/server mode on both end; I don't even know java much past "hello world" but I know that this is what its for.

      --
      Apocalypse Cancelled, Sorry, No Ticket Refunds
    19. Re:HTTP, time to update? by Fulcrum+of+Evil · · Score: 1
      You don't want to do that because your servers TCP/IP stack only has about 60K useable ports(64K ports - WKS and a few others), and each connection uses a port, then most real web pages connect to a database which means your down to 30K connections

      How precious! you think that slashdot runs on one server, and that every connection imples a connection to the database. Not so - there is most likely a connection pool, so only 20-100 connections are open from the webserver to the DB, and there are lots of boxes. In addition, there's probably a cache layer in front of the DB and in front of the webservers.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    20. Re:HTTP, time to update? by budgenator · · Score: 1

      even so the point still stands, 60 thousand user limit to connecting to images.slashdot.org isn't going to be enough; there is only ~60 K usable ports per IP address, router technics can reduce sever load but at the cost of useing more ports. Persistant connections would mean that popular sites would need more IP addresses and have to start playing technical games with DNS in order to use multilple IP addresses; which would make DNS cacheing all bu useless.

      --
      Apocalypse Cancelled, Sorry, No Ticket Refunds
    21. Re:HTTP, time to update? by Fulcrum+of+Evil · · Score: 1

      No, the point is that there is no such limit. You can build a server farm that handles a million persistent connections if that's what you need. Images is just a DNS address. It doesn't have to be a single box.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    22. Re:HTTP, time to update? by budgenator · · Score: 1

      OOPs I am wrong, looking for references to help you understand I found out that there are not 60K usable ports; there are only 16,383 useable ports!
      The ports belong to the address, one address only has 16K useable ports no matter how many boxes are connected to the address;
      slashdot.org, 66.35.250.150 have 16K ports,
      images.slasdot.org 66.35.250.55 have 16k ports,
      yro.slashdot.org 66.35.2580.151,
      it.slashdot.org 66.35.250.151
      politics.slashdot.org 66.35.250.151 have 16K ports;
      TCP and UDP port and List of TCP and UDP port numbers can explain far better than I can or will.

      --
      Apocalypse Cancelled, Sorry, No Ticket Refunds
    23. Re:HTTP, time to update? by Fulcrum+of+Evil · · Score: 1

      You just don't get it - 30,000 people can connect to port 80 on one box. If that's too much, then make it.slashdot.org 10 boxes. Your 16k port limit only applies to the number of separate services you can connect to.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    24. Re:HTTP, time to update? by budgenator · · Score: 1

      no you don't get it, it works like this ,you want to look at slashdot via the www, your computer say
      hey 66.35.250.150:80 get the web page and send the reply to 10.168.10.254:45789,
      the program apache running on the slashdot server configured to listen to address:port 66.35.250.150:80 and probably 66.35.250.150:8080, spawns a new process and attaches it to an unused port 66.35.250.150:56345 which sends the webpage to your computer at 10.168.10.254:45789; in order for slashdot to send you the page, it has to break the page down into data packets that are most likely smaller than the whole page and send them. It is assumed that the packets will be routed differently some will get to you quickly by a short route, some will get there slowly through a convoluted route, some may not get to you at all and have to be resent. The result is slashdot.org can only talk to 16K different computers at the same time period; by have connections persist in an idle state, new users will be denied service do to the lack of available ports.

      --
      Apocalypse Cancelled, Sorry, No Ticket Refunds
    25. Re:HTTP, time to update? by Fulcrum+of+Evil · · Score: 1

      program apache running on the slashdot server configured to listen to address:port 66.35.250.150:80 and probably 66.35.250.150:8080, spawns a new process and attaches it to an unused port 66.35.250.150:56345 which sends the webpage to your computer at 10.168.10.254:45789;

      No, Apache does not attach the process to a new port, it sends from port 80. A connection is defined by the host and port number of each host and whether it's TCP or UDP, so there's no reason to try weird shit with port 56345. If it sent from port 56345, how would your host ever know that that was the same connection as the one it originated.

      Go read a book - you don't know how TCP/IP works.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
  10. 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

    1. Re:Both Repetitive and Redundant by telbij · · Score: 3, Insightful
      No doubt man! Where's his editor?

      This is worse than half the stuff in my freshman comp class at community college. You don't even have to be a writer to improve this, just cut out half the words. Someone ought to introduce him to the technique of reading his writing out loud.

      Take this gem of a paragraph:

      This leads to the question of how, short of the whole kites and Igor methodology, does one accomplish this unholy task? The answer is that it depends on just how and how far one wants to pursue this course. There are three ways to bring life to an AJAX application, and each has its own advantages and disadvantages. It all depends on just which parts of the AJAX tool set the developers are comfortable with. It also depends on how comfortable you are with excluding certain members of the planet from the application. Yes, I'm talking about those people who are still running Internet Explorer Version 2.0. Fortunately, it isn't my job to issue decrees concerning browser compatibility; however, it is my job to cover how to implement an AJAX application.


      Not only does every sentence sound horrible on its own, but the whole paragraph communicates nothing at all. Well I guess it claims that there are three ways to do AJAX, but that's a pretty useless little factoid if you're not going to say what they are.

      I can't decide whether I'm embarassed for him or inspired to write a book of my own.
    2. Re:Both Repetitive and Redundant by AVryhof · · Score: 1

      I didn't know the Sphinx wrote books. What a super hero!

    3. Re:Both Repetitive and Redundant by Anonymous Coward · · Score: 0

      A handy technique when you're paid per word.

  11. Darkside by truckaxle · · Score: 1

    If you are an AJAX coder from the darkside, then this is for you.

    Notable quote "Ajax has introduced a huge attack surface"

    1. Re:Darkside by Anonymous Coward · · Score: 0

      The article mentions that MySpace was hit by the Samy worm, a worm that ran on AJAX. If I recall right, Samy was a Cross Site Scripting vulnerability that somebody took advantage of. Not an AJAX bug.

  12. Start by not putting a tag in your title :) tag by dindi · · Score: 4, Funny

    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!

    1. Re:Start by not putting a tag in your title :) tag by Decaff · · Score: 1

      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!


      Not really, because you can only successfully be cruel if you have a clue.

      Developing AJAX sites with Java is trivial - for there are many implemenations of the standard JSF web framework that are automatically provide AJAX functionality with no extra work from the developer. ICEFaces is a good example. The idea that developers should have to hand-code AJAX is way out of date (unless you are someone who enjoys that sort of thing).

    2. Re:Start by not putting a tag in your title :) tag by dindi · · Score: 1

      I have no no clue about Java but I am the person who enjoy such things as ?writing a parser? or ?using one?.

      I was referring to the fact, that badly formatted XML tends to cause problems with a lot of built-in parsers. You actually have to be very forgiving if you want to process xml written by negligent developers.

      I actually have a project, processing 38k+ feeds a day, and you would be surprised how badly formatted some are. We are talking RSS here, and from missing tags, to missing headers, to missing mime types - everything.

      I tried several JS, PHP, C++ and PERL parsers, until i found one that is forgiving enough. I went to the depths, that the parser would try to correct feeds, that are known to be badly formatted.

      That's all I meant...

      And I know that browsers won't really fall on their asses (because they do not have one) so I guess I am not that clueless.

      Ohh and I (and appearently other) find it funny, that a technical article about XML would have such an error (html being XML sort-of), as having a tag inside the title tag, which is meant to be clear text, and browsers do not parse it - format it right....

      BTW I am reading now that JSF spec on Sun, seems interesting :)

  13. Saving AJAX by Doc+Ruby · · Score: 4, Insightful

    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

    1. Re:Saving AJAX by LuminaireX · · Score: 1

      Use a scripting language like PHP, and pass "state" variables to it via the URL. For instance, mypage.php?state=15, might correspond to one of the x number of states you've determined your application is capable of. PHP generates the Javascript dependent upon this variable, and your AJAX reads from that. It's a primitive hack, but it would work in simple cases

    2. Re:Saving AJAX by crabpeople · · Score: 4, Funny

      prt scr

      --
      I'll just use my special getting high powers one more time...
    3. Re:Saving AJAX by Civil_Disobedient · · Score: 1

      How do I save an AJAX page in a given state

      Set up variables as parameters in the URL that hold the state (for bookmarking). If you can control your form values, throw in some hidden fields that hold the info on page load. If the values are empty, the ajax request uses the default, otherwise is preloads your values.

    4. Re:Saving AJAX by Mateo_LeFou · · Score: 2, Informative

      'submitting a form without reloading the page! Any easy way to do that?' I must've misunderstood the question but can't you just do an image submit button with onClick=sendFormStufftoPHPScriptThatDoesWhatever() using the xmlhttpreq object?

      --
      My turnips listen for the soft cry of your love
    5. Re:Saving AJAX by Osty · · Score: 1

      These seem to work pretty well for me anyways, but others will save all the data into some format as a cookie that can be read by both the server and the javascript which is probably the easier solution for very large apps.

      Cookies and session states are ephemeral. The OP's question could be restated as, "How do I bookmark a specific view of an AJAX web page?" This is the same problem browsers have with framesets -- the bookmark just doesn't contain enough information to tell you what page you had in which frame at the time of saving the bookmark, and it can't persist the state of an AJAXy page. The only real solution for this involves changes in browsers.

      My main problem with AJAX: submitting a form without reloading the page! Any easy way to do that?

      Hook the form's onsubmit event and cancel event bubbling. Simple. Of course, you'll need to do that in a cross-browser compatible way, which means different event attaching/detaching semantics, different event callback signatures, different ways to cancel event bubbling, etc. Any good AJAXy framework should standardize most of this for you (for example, Atlas standardizes on IE's attachEvent/detachEvent with implementations of those for Firefox -- I don't like that they chose to use the old broken IE way rather than the correct w3c/Firefox way, but the point is that compatibility is handled for you under the covers), but you'll probably still need to sort out callback signatures and event bubble cancelling on your own.

      Caveat: If you do hook onsubmit, you'll have to take care of form submission yourself (via a POST with XMLHttpRequest, for example), because you're cancelling the submission.

    6. Re:Saving AJAX by tinkerghost · · Score: 1

      Submitting a form is simple, use a post datastring in the object.send() line - and set it to 'post' not 'get' in the open statement.

    7. Re:Saving AJAX by Siberwulf · · Score: 1

      In .NEt, you can access the HttpContext.Session object by putting HttpSessionStateRequirement.ReadWrite in your AjaxMethod() declaration.

    8. Re:Saving AJAX by restive · · Score: 1

      My main problem with AJAX: submitting a form without reloading the page! Any easy way to do that?

      If you're not opposed to using a framework, use Ajax.Updater from script.aculo.us

    9. Re:Saving AJAX by TrueKonrads · · Score: 1

      Saving data to cookie is not a good idea, for one, it is limiting, for two it usually encourages some mocked up format or half-assed serialization done. AJAX is about having a useful backend, no?

      Forms can be easily submited by adding a onSubmit='myfunction();return false;' , and from that myfunc, read one by one the input elements in form and send it off. In ajax case, the only reason to use forms is that return key works as a submission key, but i suspect it can be overriden aswell. The only thing that probably can't be worked around are file uploads , as they require a proper submission.

      --
      Lone Gunmen crew.
    10. Re:Saving AJAX by Vraylle · · Score: 1

      We use this in our game. Hope it helps you a bit (sorry about the /.-limited formatting): /* Gathers form data inside parent node (any item with a value and an id). */
      function form_data(node) {var result='';var s='';var cn;for(var i=0;i<node.childNodes.length;i++) {cn=node.childNodes[i];if(cn.id){if(cn.type!='butt on') {if(cn.type=="checkbox" || cn.type=="radio") {result+="&"+cn.id+"="+cn.checked;} else if(cn.value!=undefined) {s = cn.value.replace(/\&/g,"%26");s = s.replace(/\+/g,"%2b");s = s.replace(/\%/g,"%25"); result+="&"+cn.id+"="+s;}}}result+=form_data(cn);} return result;}

      --
      Mutant Freaks of Nature: "Frighteningly Addictive"
    11. Re:Saving AJAX by Doc+Ruby · · Score: 1

      I'm talking about saving an AJAX page I'm using as a consumer in my browser. I should have been more clear in a message to a developer audience.

      --

      --
      make install -not war

    12. Re:Saving AJAX by acklenx · · Score: 1
      My main problem with AJAX: submitting a form without reloading the page! Any easy way to do that?
      Target a hidden (I)Frame.
      --
      Never let a mediocre career stand in the way of a good time
    13. Re:Saving AJAX by jozeph78 · · Score: 2, Informative
      'submitting a form without reloading the page! Any easy way to do that?' I must've misunderstood the question but can't you just do an image submit button with onClick=sendFormStufftoPHPScriptThatDoesWhatever() using the xmlhttpreq object?

      Very simple when using prototype javascript library.


      function submitForm(form) {
      new Ajax.Request("comment.php", {
      parameters : Form.serialize(form),
      onSuccess : updateComment
      });
      }

      --
      Ever done a `man` on `top` ?
    14. Re:Saving AJAX by jrockway · · Score: 1

      Yes, this functionality is part of the Prototype library:

      http://prototype.conio.net/

      --
      My other car is first.
    15. Re:Saving AJAX by cliveholloway · · Score: 1

      "My main problem with AJAX: submitting a form without reloading the page! Any easy way to do that?"

      Process form. Send the following header back to the browser:

      # Perl
      print "HTTP/1.0 204 No Content\n\n"; exit(0);

      # php
      <?php
      header("HTTP/1.0 204 No Content");
      ?>
      --
      -- Trinity in high heels carrying a whip: The donimatrix - there is no spoonerism
    16. Re:Saving AJAX by misleb · · Score: 2, Insightful

      It really depends on just how much you rely on AJAX. If you have just a single page which contains all the possible controls and functionality of your whole app, it can be quite complicated. If you just have a few ajax controls here and there and a unique HTML page for each major section, controls usually get drawn based on some database or session value so it pretty much takes care of itself. Just make sure that your ajax calls modify the screen in exactly the same way that loading the URL for the first time would.

      Where you get into trouble is when you start relying on non HTML "widgets" for controls that are drawn and managed by javascript rather than rendered by the server. I would tend to avoid this unless you have a framework that takes care of all the "state" information for you. Problem is that those frameworks can be pretty heavy and slow.

      The biggest problem with sites that overutilize AJAX is that they are difficult to bookmark. Users often want to bookmark parts of a site or send URLs to friends. If all of your app/site resides in a single page/url, nobody can link into it. This can be a bonus for people who wnat to prevent deep linking, but I think most users benefit from deep linking.

      What it comes down to is: It depends.

      Do you have a particular language/framework/application in mind?

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    17. Re:Saving AJAX by Loonacy · · Score: 1

      Why not just use a type="button" instead of a type="submit", and use an onClick event?
      The only thing I can think of is it would break being able to hit Enter on a field to submit the form, instead you could only submit by clicking the button.

    18. Re:Saving AJAX by KevinIsOwn · · Score: 1

      Man look at these people go with all these solutions. Parent poster clarified and said as a consumer of a webpage- The viewer! This is a good question and the way I do it is with the Firefox "Web Developer" extension. Then all you have to do is right click, go to Web Developer > View Source > View Generated Source.

    19. Re:Saving AJAX by potHead42 · · Score: 1

      Have a look at Prototype, in particular Form.serialize().
      Oh, and Ruby on Rails has helpers for this too, of course.

    20. Re:Saving AJAX by Anonymous Coward · · Score: 0
    21. Re:Saving AJAX by ShecoDu · · Score: 1

      The Ajax Toolbox has a function that lets you do exactly that, submit a form via javascript. It just doesn't support file input fields for obvious reasons.

    22. Re:Saving AJAX by Doc+Ruby · · Score: 1

      Actually, what I had in mind was that bookmarking you mentioned. I should have been more clear in a post to an AJAX development thread. But it's also been interesting seeing state-saving advice for the server.

      A better way to ask might have been to ask how to offer AJAX client users better state saving features than, say, Flash offers.

      --

      --
      make install -not war

    23. Re:Saving AJAX by Doc+Ruby · · Score: 1

      Right. I was hoping for at least a discussion on client UI paradigms ("Save As..." button vs "save on load" event etc), or client-side sandbox/virus issues, or just client-side vs server-side storage.

      My own basic take on the use case is client-side caching (maybe in a cookie) as states change to meaningful "milestone" state points, stored persistently at the server, all by the applet POSTing URLs without needing to update the GUI.

      --

      --
      make install -not war

    24. Re:Saving AJAX by labreuer · · Score: 1

      This is a little late, but most browsers keep the current state of all form elements cached so that the back button will repopulate text boxes and whatnot. This means you can store state in hidden input elements and have a restore function that runs from the body's onload event. The onload event fires when the page is loaded from cache, as well as loaded from the web server.

    25. Re:Saving AJAX by Achromatic1978 · · Score: 1

      Even that can be fixed depending upon your form structure - bind an onkeypress event to form submission too.

    26. Re:Saving AJAX by LuminaireX · · Score: 1

      You would provide that link as a reference to the consumer to come back to the current state later. ie, a link given to the user as "mypage.php?state=15" would allow the user to return the page at state 15 whenever they wish

  14. Iframes by bobs666 · · Score: 1
    I use iframes, no java needed. I have tryed PELR::AJAX,
    but leave it to MSIE to break on all but the simple stuff.
    Can't get my users to just use firefox.

    So for me iframes work best.

    1. Re:Iframes by bw-sf · · Score: 1

      What's Java got to do with anything? And what's Perl got to do with browser compatibility? Weren't you using Java a minute ago? I suspect you have no idea what you're doing.

    2. Re:Iframes by goodenoughnickname · · Score: 1

      Was that a haiku?

  15. 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
    1. Re:Huh by El_Muerte_TDS · · Score: 1

      There is nothing wrong with the HTML button element (well, except that MSIE doesn't understand completely).

      <button type="submit" onclick="doAjaxStuff(); return false;">submit my input</button>

      works perfectly and is far superior to the lousy <input type="submit" value="submit my input" /> variant.

    2. Re:Huh by Bogtha · · Score: 1

      Sorry, I wasn't very clear there. My problem isn't simply with <button> (although <input type="submit"> is better supported by browsers, which is critical, and it submits the wrong data in Internet Explorer as you point out), but rather that practically everybody who uses it uses it instead of the mandatory action attribute on the <form> element - in essence, throwing away the HTML functionality and replacing it with less compatible JavaScript. I've simply never seen anybody use <button> with a properly coded form.

      --
      Bogtha Bogtha Bogtha
  16. 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

    1. Re:There are much better intros to Ajax by supun · · Score: 2, Informative

      I like Sarissa, but have moved onto using Dojo http://dojotoolkit.org/ due to it's friendlyness to JSON. Much easier accessing a returned object that walking the DOM.

      --
      :w!
  17. Java and Ajax by coldtone · · Score: 1

    If your a Java coder Icesoft has a great AJAX framework icefaces.

    1. Re:Java and Ajax by coldtone · · Score: 1

      Found a good demo link Here

  18. abcdefghijklmnopqrstuvwxyz by Anonymous Coward · · Score: 0

    abcdefghijklmnopqrstuvwxyz

  19. Don't overdo the XHR by JesperJ · · Score: 1

    I think it's important to keep the XML HTTP Request (or AJAX if you want) seperated from explicit changing topic or direction. Someone above me said that "you never have to see your page refreshing again". I think XHR should be enclosed to only where it really belongs and would be very neat - for instance in the slashdot comment system or just comment systems in all general; Not to change the subject all over.

    If XHR's not being overdone, you ensure that links still works, later on you can separate the overall content on different topics and so on. Browsing the web should be preserved for refreshing.

    1. Re:Don't overdo the XHR by tmasssey · · Score: 1

      They're working on it.

      I'm participating in an AJAX adaptation of /.'s comment page. It has some functionality for controlling exactly which comments are visible and not. Seeing as I browse at a pretty low level already (not -1, but close), these features have been uninspring for me. But the ability to click on a collapsed comment and get it to come up, or to collapse an entire tree that's spiralled out of control without having to refresh the entire page is *gold*.

      P.S.: Does anyone know of a way to get a paragraph break without wrapping the entire paragraph in <P> and </P> tags?

    2. Re:Don't overdo the XHR by Jett · · Score: 1

      Have you guys seen the dailykos comments? They are by far the slickest comments I have ever seen and one of the best implementations of AJAX methods outside of Google.

    3. Re:Don't overdo the XHR by Bogtha · · Score: 1

      I'm participating in an AJAX adaptation of /.'s comment page.

      If you're talking about the University of Michigan's work, firstly, I'm not sure Slashdot are actually going to use anything like that, I think it's just research. But as well as that, I've been a web developer since the late 90s, and in all that time I don't think I've ever seen anything presented to an end user that is half as buggy and non-functional as that new comment system. It's horrendous.

      P.S.: Does anyone know of a way to get a paragraph break without wrapping the entire paragraph in <P> and </P> tags?

      It's impossible to give you advice on the matter because you've left the most important piece of information out: what is it that you are marking up? It sounds like either you do actually want <p> elements or you don't want a paragraph break, but a vertical margin/padding. A paragraph break, by definition, is a break between two paragraphs.

      --
      Bogtha Bogtha Bogtha
    4. Re:Don't overdo the XHR by Anonymous Coward · · Score: 0


    5. Re:Don't overdo the XHR by koh · · Score: 1

      />

      --
      Karma cannot be described by words alone.
    6. Re:Don't overdo the XHR by tmasssey · · Score: 1

      It's probably too late to reply to this...

      Yes, the UM research stuff. I haven't had any bugs that I've noticed. I'm running FX 1.5.0.6 or so, and haven't seen anything that led me to believe that something was wrong. The stupid control box is kind of ugly and weird, but once I figured out a decent set of settings, it's worked well.

      There are two things I really like about it: the ability to quickly open and close posts that I want to read, but aren't on the screen fully, and the ability to close an entire tree that's branched into something off-topic. For example, I can quickly close the entire tree that will be talking about DRM on every story, no matter how unrelated it might be! :)

      Part of the need for that is the fact that I tend to have very low standards for what I allow to be fully displayed. Basically, anything that's at 1 or higher is expanded, and anything besides -1's that are even remotely attached to something that's been modded up. That means that the majority of comments are shown fully, and the remaining ones show at least a sentence. So the ability to collapse parts of the tree that have spun out of control is big.

      As for the comment about paragraph tags: I'm talking about paragraph breaks in Slashdot. I used to just throw a <P> at the end of the paragraph, like pressing . But that won't work since the CSS redo. Now I actually have to include my text in matching P tags. That's annoying, and I inevitably miss some. I guess I can just enter a double-<BR>... Not a terribly big deal, I guess...

  20. Use Echo2 by Mock · · Score: 4, Informative

    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.

    1. Re:Use Echo2 by timeOday · · Score: 1

      That's pretty cool. Here's their demo. After clicking through this, I have to say: for all the mockery of "Web 2.0" around here, there is a HUGE change from 10 years ago (writing static pages in html) to this demo (writing what appear to be fairly normal applications in Java, where supposedly the developer avoids the grab-bag of "web technologies" altogether). I realize the exact choice of when to use a new major version number is somewhat arbitrary, but things really have changed. Too bad it's almost impossible to write a fully functional web browser from scratch anymore, but could it be that real, general-purpose hosted office apps are finally becoming a reality?

    2. Re:Use Echo2 by master_p · · Score: 2, Interesting

      I have been developing an intranet application with Echo2 for 3 months now. Although the concept is great, it takes a lot (and I mean A LOT) of effort to write the GUI using Echo2:

      1) the Eclipse plugin is shareware. Since the project I am doing is small, no extra expenses were allowed, so I did everything manually.

      2) the widgets are minimal, to say the least. The core library contains very few widgets (button, label, text field, text area, table, grid, row, column, splitpane, windowpane). You have to download an extras library.

      3) the widgets' look and feel is 'black text and white background'. You have to manually specify the visual output for all states of each widget. For example, you have to specify, for the button, the background color, border, font color for each of the disabled, enabled and selected states.

      4) The above is somehow solved with styles provided in XML. But this part of the library is totally undocumented. I mean there is not a single line of documentation of how the XML style files should be. I posted the relevant question in their forum and they said to look at the examples.

      5) The GUI is single-threaded (each connection has its own thread). If you want to add something to a model from another thread, you have to write a task which will be executed in each client's message queue. Which means that you either make new models which are synchronized or each client maintains different model instances for the same data...which means a huge waste of memory.

      6) geometry management is weird, to say the least. Many components do not autosize themselves to the available space of their containers or have weird constraints. You have to use splitpanes for most tasks, but they have some severe drawbacks: panes can not be children of non-panes.

      7) widgets are pretty limited in functionality. For example, there is no way to scroll a text area content to the last line in order to simulate a command prompt window, for example.

      8) there are maybe some weird bugs in it. Some times the communication between browser and server freezes, even if both are on the same machine.

      9) data validation on the client is not existent. You just accept whatever the client sends you.

      Overall, Echo2 is pretty average...the concept of 'all Java' is great and saves you a lot of trouble...but I think Echo2 needs a great deal of work to make it really good.

      What I would like to see is Java bytecodes be translated to ecmascript and run on the client. That would save many hours of coding, as well as make applications much faster and nicer. For example, I would like to write a data validation routine in Java, and I want this routine to be translated to javascript and executed on the client side, thus not needing to get back to the server and bog down the network.

    3. Re:Use Echo2 by Anonymous Coward · · Score: 0

      Please write this up in a blog and post a submission to theserverside. The echo2 developers always brag about how easy it is to devlop with their framework.

      Last paragraph: GWT should do this

  21. Comment removed by account_deleted · · Score: 3, Insightful

    Comment removed based on user account deletion

  22. How do I? by Anonymous Coward · · Score: 0

    With the CGI::Ajax Perl module: http://perljax.us/

  23. Well written by Morinaga · · Score: 1
    I'm no expert when it comes to coding up a web page. The page I'm responsible for in my little corner of my organization I just update with straight HTML edits in notepad. I can't vouch for the technical expertise of this author but I for one appreciate technical material that is easy to read and God forbid, a pleasant experience.

    What is AJAX?

    As stated previously, AJAX stands for Asynchronous JavaScript And XML, but what exactly does that mean? Is the developer limited to only those technologies named? Thankfully, no, the acronym merely serves as a guideline and not a rule. In some ways, AJAX is something of an art, as with cooking. Consider, for a moment, the dish called shrimp scampi; I've had it in restaurants up and down the East Coast of the United States, and it was different in every restaurant. Of course, there were some common elements, such as shrimp, butter and garlic, but the plethora of little extras added made each dish unique.

    The same can be said of AJAX. Starting with a few simple ingredients, such as HTML and JavaScript, it is possible to cook up a Web application with the feel of a Windows or, if you prefer, a Linux application. You might have noticed earlier that my ingredients list omitted XML; the reason for that omission is that XML is one of those optional ingredients. This might sound strange because the x in AJAX stands for XML, but it is also useful in those instances when a particular client does not support XML or doesn't support some of the more "mad scientist" methods of communicating with the server.

    AJAX, yummy.

  24. Solution looking for a problem? by catbutt · · Score: 2, Insightful

    Are you suggesting that it didn't occur to those who created XMLHttpRequest how it might be used?

    I think it was far more a case of it taking a while for someone to make a compelling enough application using it for it to get public acceptance and attention from mainstream developers. And probably a bit of reluctance to go down that path until a large enough percentage of users had a browser that supported it to make it make economic sense to invest in the use of such techniques on a large scale.

  25. You don't... by ncannasse · · Score: 1

    To use AJAX... you don't write Javascript ! Use instead GWT or haXe.

  26. Nobody calls XmlHttpRequest() directly anymore by IGnatius+T+Foobar · · Score: 4, Insightful

    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!
    1. Re:Nobody calls XmlHttpRequest() directly anymore by richdun · · Score: 3, Informative

      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.

      What does that do that this doesn't (other than use a pretty wrapped package)? This is the general form I use for my AJAX requests. If needed, I add some checking to cancel previous requests to the same method or queue successive calls so that the race for responses doesn't screw me up. It seems to work in all browsers I test for (IE6, FF 1.5+, Opera 9+, Safari 2+...and yes, I force my users to use modern browsers).

      if (window.XMLHttpRequest) {
              var oHttpRequest= new XMLHttpRequest();
      }
      else if (window.ActiveXObject) {
                      var oHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }

      function ajaxCall (page,params,responseHolder) {
              oHttpRequest.onreadystatechange=function()
                      if(oHttpRequest.readyState==4) {
                              document.getElementById(responseHolder).innerHTML = oHttpRequest.responseText;
                      }
              }

              oHttpRequest.open("POST",page,true);
              oHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
              oHttpRequest.send(params);
      }

    2. Re:Nobody calls XmlHttpRequest() directly anymore by IGnatius+T+Foobar · · Score: 2, Insightful
      What does that do that this doesn't (other than use a pretty wrapped package)?

      Well, for one thing, where you wrote 16 lines of code, doing the same thing in Prototype would have taken 1 line of code. Isn't that the point of wrapper libraries? To make repetitive, commonly used tasks like this one more convenient? (Not to mention, the 1-line Prototype call would also work in IE5 and FF1.0)

      --
      Tired of FB/Google censorship? Visit UNCENSORED!
    3. Re:Nobody calls XmlHttpRequest() directly anymore by richdun · · Score: 1

      Isn't that the point of wrapper libraries? To make repetitive, commonly used tasks like this one more convenient?

      Absolutely. I just consider myself still in the learning phase of the AJAX part of my web apps (good with PHP, good with XHTML/CSS, not so great with advanced Javascript), so I like to do some of the common repetitive things so I'm not doing a typical plug and chug job at coding without understanding well what's going on underneath. It's mostly just for my own benefit - I see too many jump into libraries without understanding really what they do, and then throwing their hands up when the library does something they weren't expecting. But it's good to know that Prototype works that well - I'll have to look into it once I'm a bit more comfortable with what I'm doing.

      IE5...pfft...compatibility...who needs that?

      I failed to mention that I develop mostly internal apps for a very small organization, not for public consumption, so I can get away with demanding that everyone has a particular class of browser.

    4. Re:Nobody calls XmlHttpRequest() directly anymore by IGnatius+T+Foobar · · Score: 1

      Cool, if you're doing it to have the best possible level of understanding of the architecture, then more power to you. I can't say I've never done that -- the web interface to my primary software project is written in C and contains its own web server. How's that for archaic? :)

      --
      Tired of FB/Google censorship? Visit UNCENSORED!
    5. Re:Nobody calls XmlHttpRequest() directly anymore by roman_mir · · Score: 2, Insightful

      because, in case you're not already aware, XmlHttpRequest() returns its data asynchronously - that's what you get for not getting into the details of implementation and for always using some libraries to do things for you. It is possible to make synchronous and asynchronous calls with XmlHttpRequest.

    6. Re:Nobody calls XmlHttpRequest() directly anymore by leighklotz · · Score: 3, Informative

      One good mechanism for getting the XML and asynchronous features but without hand coding JavaScript is to use any of the various XForms implementations. XForms is a W3C standard that defines a mostly script-free way of doing much of stuff people want out of Ajax, and it's done in a declarative way that's friendly to accessibility agents, and easier to deploy onto other devices. I was an editor of the XForms 1.0 recommendation, but new revisions have come out; see http://www.w3.org/TR/xforms

      The FormFaces OSS product is an entire XForms implementation done in JavaScript, running in the browser. You write your page in HTML with XForms markup, and FormFaces does the "HiJax" thing of re-writing it for you. You never need to use XmlHttpRequest, and you can interact with regular servers, RESTful services, etc., all via XML.

      Another product that does this, in a slightly different way, is AjaxForms. I just found out about it, but it looks pretty good. AjaxForms uses some server-side components to do the translation from strict XHTML+XForms markup into Ajax (HTML4+JavaScript), but they claim it can work in PHP and Tomcat servers. Again, FOSS, and available at http://ajaxforms.sourceforge.net/

      I recently implemented dynamic forms for weblogs and wikis, and did it using Chiba, another FOSS product, that like AjaxForms does its conversion on the server, using Tomcat as a container.

      Another important option is the work that the Mozilla Foundation and IBM are doing to make a native implementation of XForms as an XPI for Firefox and Mozilla. See http://www.mozilla.org/projects/xforms/ -- they're now in version 0.6, with 1.0 targeting full XForms 1.0 compliance. Like all other Mozilla extensions, it's a 1-click install, and I think it's about 200KB, so it's not very big, and I hope it gets added to the default build after it reaches 1.0. (It's presently built with the nightlies.)

      There are a number of other implementations, including browser plugins (FormsPlayer for IE), native implementations for embedded devices such as cellphones and kiosks (PicoForms, SolidForms, and entire server-side systems using XForms, such as Orbeon Ops, so I see an increasingly bright future for using XForms to build dynamic HTML interfaces on top of XML web services and deploy them across a range of devices.

    7. Re:Nobody calls XmlHttpRequest() directly anymore by a.d.trick · · Score: 1
      What does that do that this doesn't

      Works with XHTML.

    8. Re:Nobody calls XmlHttpRequest() directly anymore by plimpton · · Score: 1

      does it evaluate javascript in the returning page? Nope, I use that every day

    9. Re:Nobody calls XmlHttpRequest() directly anymore by richdun · · Score: 1

      Actually, that does work with XHTML if you have the PHP (or whatever) file properly construct the responseText and throw it into a as the responseHolder. I mean, it doesn't actually know that it is XHTML, but it still works as such (i.e., applies stylesheets, validates, etc.)

    10. Re:Nobody calls XmlHttpRequest() directly anymore by richdun · · Score: 1

      Yeah, it just dumps whatever the response was into your holder. I mostly just use it to go get new data from a DB then put it into a or something on the page. I guess you could though chain whatever Javascript you wanted into the onreadystatechange function, but that'd require you to know what to do after the response AND have the code available to write in before the response is gained - something simple like change the color of the box to the backgroundcolor of a returned could be done if you do it right, but it wouldn't be fun or simple or maybe even get where you want it.

    11. Re:Nobody calls XmlHttpRequest() directly anymore by a.d.trick · · Score: 1

      No, because the innerHTML method doesn't work with XML (and XHTML is a form of XML). I'm assuming that your sending the proper XHTML mime type and everything.

  27. Real world issues... by Aeomer · · Score: 1

    The collection of tools that make up AJAX are as well integrated and easy to work with as the collection of pseudo autonomous regions of North America that make up the United States.

    AJAX as a whole has fewer bugs though. ;-)

    1. Re:Real world issues... by Anonymous Coward · · Score: 0

      Uhh, What?

      I don't mean to go on a rant here but your post about the pseudo-autonomous regions that make up the United States makes about as much sense as a Beowulf having sex with Robert Fulton at the first battle of Antedem. I mean when a neoconservative defenestrates it's like Riskalnikov filabuster dioxymonohydroxinate.

    2. Re:Real world issues... by Anonymous Coward · · Score: 0
      I don't mean to go on a rant here but your post about the pseudo-autonomous regions that make up the United States makes about as much sense as a Beowulf having sex with Robert Fulton at the first battle of Antedem. I mean when a neoconservative defenestrates it's like Riskalnikov filabuster dioxymonohydroxinate.


      Seems they don't teach lateral thinking in the Gud Ol' US of A.
  28. AJAX and Search Engines by big_a · · Score: 2, Insightful

    One strike against AJAX is that search engines won't be able to see any of your 'dynamic' content. Sure, you can code around it by providing static links to the same content, but it's something to keep in mind.

    1. Re:AJAX and Search Engines by Vraylle · · Score: 1

      I hear you there...thought it's not that big a loss for our game. I experimented with integrating AdSense into our game's content, which actually worked for a while. At first the ads anaylzed the dynamic content within the same context and provided appropriate ads (and very funny...you'd have to be familiar with the game and have seen the ads to fully appreciate it). A day or two after Google's crawlers tried unsuccessfully to index that part of the game, the ads reverted to PSAs. I tried to work with Google on it, but it turned out what I was doing was actually against AdSense policy, and they weren't interested in supporting dynamic content.

      --
      Mutant Freaks of Nature: "Frighteningly Addictive"
    2. Re:AJAX and Search Engines by acklenx · · Score: 1
      they'll be able to see your dynamic content if you link to it, and that link returns content.
      <a href="sameCoolContent.html" onclick="useAjaxToGetAndShow( this );return false;">Cool Link
      <script>
      function useAjaxToGetAndShow( oLink )
      {
      var sContentUrl = oLink.href
      // call Ajax
      }
      </script>
      More importantly, how in the /. do you insert codeblocks?! I don't care who depricated <xmp> it's still the best way. What does everyone else use to show formatted code on /. surely not &lt; and <br />
      --
      Never let a mediocre career stand in the way of a good time
  29. Not Magic by MattW · · Score: 2, Informative

    We didn't really even need xmlhttprequest; you could use iframes, too. (And some notable "2.0" apps have)

    Useful bits I've found getting into ajax stuff:

    Dojo Toolkit, a nifty framework for doing all sorts of good stuff. Of particular note to me was dojo.io.* with its dojo.io.bind() function, which provides a simple, cross-platform compatible way to do an xmlhttprequest, with callback functions for completion and errors, an easy way to post variables, specify a method and caching, etc.

    openrico. This provides all sorts of fun stuff. The smart stuff starts with declaring $ as a function, which after you get used to it provides a very convenient cross-platform way to access DOM nodes (ie, $('mydiv') or $(divvar)), and has all sorts of canned widgets for effects, like accordian widgets, move&resize, etc... although I've found practical application usually requires a bit more additional work, but their functions help get started.

    1. Re:Not Magic by wranlon · · Score: 1

      On the framework topic, I've been working on one with AJAX support since 2002: Engine for Web Applications (Example). The XML utility also exists standalone as libXmlRequest, and includes both request object and response content caching.

    2. Re:Not Magic by acklenx · · Score: 1

      But if you say IFrames, suddenly it's not AJAX anymore. I mean when you click on things with iframes you hear it... yuk. Oh and the back button doesn't work with Iframes.

      Damned if you do damned if you don't. I think the best thing to tell people to ground them in AJAX is that it's just like button rollovers that were all the rage some years ago (and to some extent still are).

      onmouseover="loadDifferentImage()"

      AJAX is the same thing except that instead of a binary image, you can send text instead. If _may_ even be XML, and there is a possibility that i could be sent asynchronously if you wanted. The only part that seems pretty consistent with AJAX is that it uses javascript.

      Hell I've even accomplished the same effect when I was given the requirement for the basic AJAX behavior, but not allowed to use (i)frames or ActiveX. I just queued up images and passed the text in the cookie. All of what makes AJAX cool is Javascript and DHTML. The AJAX part is really only a couple of lines of code, and the name is a complete misnomer.

      --
      Never let a mediocre career stand in the way of a good time
  30. No for me! by Anonymous Coward · · Score: 0

    I leave "crazy quilt"'s to my mommie.

    I use _one_ language and write _one_ apache module.

    End of story... Nothing to see.. Move along..

  31. Article writer looking for a brain by Anonymous Coward · · Score: 1, Insightful

    Beyond the XMLHTTP Request object, which has been around for several years as a solution looking for a problem...

    Outlook Web Access, genius. That's the problem Microsoft made it to solve.

  32. nu-uh. by Supersonic1425 · · Score: 1

    Start > Programs > Accessories > Notepad2

  33. simple AJAX example by Anonymous Coward · · Score: 0
  34. Cred went to zero in the summary by YU+Nicks+NE+Way · · Score: 2, Interesting
    the XMLHTTP Request object, which has been around for several years as a solution looking for a problem, there is nothing weird needed
    OK, so this guy doesn't even know that HttpRequest was added to MSXML to allow OWA 2000 -- you know, the first Ajax client -- to work. SOunds like he's got some technical issues to work through first.
  35. In Soviet Russia... by Anonymous Coward · · Score: 0

    ...AJAX codes YOU!!

    1. Re:In Soviet Russia... by RafaelGCPP · · Score: 1

      A good joke never gets old...

      --
      "There is always an easy solution to every human problem -- neat, plausible, and wrong."
      H. L. Mencken
  36. 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.
    1. Re:Oh yeah? by Anonymous Coward · · Score: 0

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

      Maybe you checked "post anonymously" by mistake?

  37. 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

    2. Re:Speaking of AJAX... by runep · · Score: 1
    3. Re:Speaking of AJAX... by Anonymous Coward · · Score: 0

      Wasted bandwidth?

      Currently, browsing at level 3 (nested), I'm viewing 30 posts (the only ones I'm likely to read). Using ajax would add javascript to each page (longer load times, more BW costs, etc), and it would likely load the whole thing and expand/collapse parts - more like dhtml tricks than ajax really (making the page load hundreds of tiny parts of the discussion upon clicking expand would require more code than the whole page w/ all posts takes i.e. code for each node and endless id tags on each, and would unecessarily make MANY times more http requests to the servers).

      Not to mention that people will reload pages anyways, because the content isn't static. There are people posting all the time.

      It doesn't really make sense. It would just become a gigantic less of JS, take forever to load, and bring nothing interesting. AJAX is nice, but it's not the solution to every problem, and an automatic "should be in every web page" thing.

    4. Re:Speaking of AJAX... by foo+fighter · · Score: 1

      It's really terrible right now. It has a very confusing UI and doesn't work well in Safari. I tried it for a week and found I hated visiting Slashdot. Good way to break a bad habit I guess, except here I am again. YMMV

      --
      obviously no deficiencies vs. no obvious deficiencies
    5. Re:Speaking of AJAX... by Anonymous Coward · · Score: 0

      And, please, an automatic preview area to see what you are submitting without pushing preview button.
      Like this blog live preview

  38. AJAJ, not AJAX by Vraylle · · Score: 1
    We ended up creating our own library for our browser-based game. There weren't any good freely available ones when we started. Data is returned in JSON instead of XML, where each key=>value pair indicates a bit of script that is executed or a DOM object that is updated (rough overview). If the object is a div, the value goes into innerHTML or the textNode; if it's a button it goes into the caption; for a checkbox the value is parsed into the checked property, etc. A single returned "set" will have several of these, so it often sends back a small chunk of HTML, with subsequent orders setting its contents and adjusting the interface.

    The server code has a DOM class with methods to send scripts, HTML, etc. with all the URL encoding/quote escaping/etc. handled automatically. It continues to be refined but already enables us to do some really nifty stuff.

    Later I integrated the Prototype library, and it does seem to do a better job of handling XMLHttpRequests than our original library did.

    --
    Mutant Freaks of Nature: "Frighteningly Addictive"
  39. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  40. HTTP, time to update?-XMPP by Anonymous Coward · · Score: 0

    "With the growing popularity of AJAX does anyone think it's time to update the HTTP spec?"

    I'd recommend XMPP and Jep-0124

  41. do it yourself by appleloaf · · Score: 1

    As far as anything ajax should ever be applied to, all the javascript libraries and such, often worse, gunk dancing around the name ajax are just bloat where you could accomplish your goal with hundreds fewer lines of your own code - you don't need most of the stuff thats there, and it encourages you to do things you shouldn't. Ajax just isn't something you ever (should) need more than a request function and a callback function or two for unless you're going GMail on your users. Beside whether you should use it at all. It can be nifty, but often its use is abusive to its medium.

    If you're going to do it, don't bloat it, and know what you're doing. Just write yourself a hundred (or, hell, way fewer if it's a half simple use) lines of javascript instead of implementing some huge general purpose thing under some lisence and crap like that.

  42. no ActiveX examples anymore, please by Anonymous Coward · · Score: 0

    This is a pretty good reading about AJAX but they'd better not use any ActiveX in their examples anymore. ActiveX is:

    a.) not a standard
    b.) a huge security risk
    c.) should not be used anymore by any serious web developer for above reasons

    There are other simple AJAX examples that don't use ActiveX anymore.

  43. Ajax + Risk = Grand Strategy by bryanbrunton · · Score: 3, Interesting

    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/

    1. Re:Ajax + Risk = Grand Strategy by Anonymous Coward · · Score: 0

      Will it work if javascript for that site is disabled in my browser settings ?

    2. Re:Ajax + Risk = Grand Strategy by bryanbrunton · · Score: 1


      It will not. Sorry haven't gotten around to putting in a noscript tag yet.

  44. Ajax and the endless dodgy code by Anonymous Coward · · Score: 0

    I agree. The code harks harks back to the days of Netscape 4 with lots of ugly hackery.

    Aside from the article, AJAX seems like a nightmare of curious dodginess. We were all taught not to use frames, to use javascript sparingly.. where is this all going, because Google made a couple of apps ?

    Have you tried google maps on a slow connection ? runs like a 3-legged dog.

  45. Not the best approach by brunes69 · · Score: 1

    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

    Without knowing really your level of experience in designing dynamic AJAX-driven sites, I can say at least this coment in particular is complete bunk. For one, hooking into the 'onsubmit' form event is a recipie for disaster - the event behaves entirely unpredictably across different browsers. Some allow you to cancel it, some don't, others only in certain situations. This is a complete disaster when you're trying to use AJAX to reduce page loads, because normally you would want to submit the form fieldsw to the server for validation and display the error if they did nto validate - and cancel the form submission.

    Anyone who has done AJAX in any reasonable amount knows, it is just too different a paradigm to integrate alongside an old HTML 4.0 compatable page in any resonable way. With AJAX, you usually want a totally different layout, and a totally different way to display information. Sure, you *can* make them work side by side, uising crazy CSS and javascript that basically re-dos the whole page based on the browser's capabilities. But why would you do that? The best way to do things, is to have two completely different sets of forms - one AJAX-ified, one not. The number of browsers that support AJAX is small enough that you can redirect them to the fancy site based on the User-Agent.

    1. Re:Not the best approach by Bogtha · · Score: 1

      For one, hooking into the 'onsubmit' form event is a recipie for disaster - the event behaves entirely unpredictably across different browsers. Some allow you to cancel it, some don't, others only in certain situations.

      Which browsers would these be? I find that the submit event can be reliably cancelled if you take into account a) DOM-capable browsers, b) Internet Explorer, and c) other old-fashioned browsers. There's three different ways of cancelling an event, are you sure you aren't forgetting one of them?

      Anyone who has done AJAX in any reasonable amount knows, it is just too different a paradigm to integrate alongside an old HTML 4.0 compatable page in any resonable way.

      I disagree. As long as you get the foundation right, it's easier, less buggy and more user-friendly to have a single codebase instead of having to maintain two separate versions. But that's dependent on getting the foundation right, and from what I can see, not many web developers do because they jump in and start learning JavaScript before they've finished learning HTML.

      I don't know what you mean by "old HTML 4.0 compatible page". Ajax is completely compatible with HTML 4, I use it with HTML 4, they aren't competing technologies, they are complementary technologies, even when you create an interface that's totally dependent on Ajax, you're still working within the HTML 4 framework.

      With AJAX, you usually want a totally different layout, and a totally different way to display information.

      Sometimes this is the case, but it's rare. A list of items is still a list of items regardless of whether you click a button to rearrange them or drag and drop them. A form to fill out is still a form to fill out, even if the username is dynamically checked while you're still filling out the rest of the page. A list of search results is still a list of search results, even if it gets displayed while you are still typing your query. An unread message counter is still just a number regardless of whether it's updated when you refresh the page or every few seconds.

      Ajax isn't usually used to create a radically different interface, just to streamline and speed up an existing interface. Even when the layout is different, that's usually a case of linking in another stylesheet, not radically altering the page itself.

      The number of browsers that support AJAX is small enough that you can redirect them to the fancy site based on the User-Agent.

      Horrible idea. Even if you detect the user-agent reliably (most people don't), that doesn't tell you whether it supports Ajax. I already mentioned one case where this would break - when ActiveX is disabled in Internet Explorer. Like I already said - browser detection is stupid and wrong. If you're going to go to the trouble of creating two entirely different versions, at least have the good sense to pick the right one properly.

      --
      Bogtha Bogtha Bogtha
  46. next.... by burnin1965 · · Score: 2, Insightful

    After reading through five pages it all ended at "var dom = new ActiveXObject(......"

    No thanks, next book please.

    1. Re:next.... by Ed+Woychowsky · · Score: 1

      Hey, it is only an excerpt. In later chapters I go into how this is accomplished in other browsers. Actually, Firefox is my favorite browser, it provides better diagnostic messages.

  47. AJAX is too old.... by corychristison · · Score: 1

    I'm even more bleeding edge.. I use ADHJACS. ;-)

  48. Time to put up or shut up by Anonymous Coward · · Score: 0

    For those of us who aren't experts in this but may be interested in learning something new, how about a concrete example? Give us a simple, complete page that uses AJAX and is still compatible with non-AJAX browsers. None of this "there are ways to do ..."

    Thanks!

    1. Re:Time to put up or shut up by Bogtha · · Score: 2, Informative

      Give us a simple, complete page that uses AJAX and is still compatible with non-AJAX browsers.

      Off the top of my head: Google Suggest. The same page offers enhanced Ajax functionality and still works in Lynx, without any need for two pages or radically different layouts.

      The ways you make Ajax work in a backwards-compatible manner are the same techniques decent JavaScript developers have been using for years. Unfortunately, not a lot of people are aware of JavaScript best practices and the field is still dominated by people who concentrate on making it work in their favourite browser and then bodging it to work elsewhere, rather than starting from a good solid design and enhancing it in a structurally sound manner.

      If you're interested in learning more, I suggest DOM Scripting and the DOM Scripting Task Force website as decent starting points. I haven't read the book, but I've heard a lot of good things about it from people who know what they are talking about.

      --
      Bogtha Bogtha Bogtha
  49. Prototype by ManoSinistra · · Score: 1

    The Prototype script library provides an excellent base for AJAX (as well as other dynamic Javascript effects). I like to use that since it's very hard to make AJAX cross-browser compatible as it seems that every browser has a different way it would like the XMLHHTP to be formatted . . . I prefer to work off of what has already been tried and true.

    Moo.ajax.js also provides an easy (and light) way to do AJAX very easily (using a "lite" version of prototype as a building block). In fact, moo.fx.js (another lightweight script library from the same folks) is used on this very site to accomplish the collapsible menu on the left.

  50. much ado about DIV innerHTML = stuff by usidoesit · · Score: 0

    once you get that the rest falls into place. don't need to read a 10 page article.

  51. Cross-platform to limited users? by tepples · · Score: 1
    You want to do a constant-state, client-server thing? Then write a socket app.

    What is the easiest way to deploy a socket app cross-platform to a Limited User who cannot run untrusted executables? Do you really want your banking software to go back to client software that runs only under Microsoft® brand Windows® brand operating systems?

    1. Re:Cross-platform to limited users? by richdun · · Score: 1

      No, but I'm not sure I want a constant connection to my bank open either. It's like running a package through a gauntlet - make it through by running fast, but then only run back when it's safe. Stay in the gauntlet and someone's bound to grab you.

  52. Java 1.5 or Java 1.1? by tepples · · Score: 1
    why not just write a java applet?

    Because not enough people have Java 1.5 or newer installed. Remember that IE doesn't come with anything later than MSJVM 1.1.x, and not everybody 1. has permission to install software, 2. is willing to learn to install software, 3. is willing to install a binary from someone they never heard of ("Sun? Who's that? Some Japanese company? Is this spyware?"), 4. is running on a platform to which Java 1.5 has been ported, and 5. has a fast enough connection to download Java 1.5 without the phone line clicking off after an hour.

  53. TiddlyWiki by mutende · · Score: 1

    TiddlyTiki is a neat self-contained wiki engine that uses AJAX to get the job done.

    ZiddlyWiki was a TiddlyWiki incarnation for Zope. Unfortunately it seems its author, Tim Morgan, let it die just a few days ago...

    --
    Unselfish actions pay back better
  54. uhm by Anonymous Coward · · Score: 1, Informative

    not to be such a nerd, but this tutorial is ie-oriented (war!) but anyway, mozilla.org ironically has had the same thing .. only more expanded, with less ads, and for all major browsers (including ies) here: http://developer.mozilla.org/en/docs/AJAX ... for a long time now ...

  55. Xajax by Delifisek · · Score: 1

    Well,

    For Php scripters, if you want to create ajax based web pages, have to look xajax. It was so easy you do not need to know javasciprt.

    --
    [My english is better than most other people's Turkish, so please point out mistakes politely. Thank you.]
  56. You code an AJAX by... by zarlino · · Score: 1
    1. Preventing access by people with any kind of disabilities
    2. Preventing access by people using devices/browsers that do not support the latest client-side script tricks
    3. Making information non-addressable from other pages
    4. Ensuring it can't be indexed by search engines
    5. Removing any visual clue that something is loading, so that the user will wait forever if there's a server/network problem
    6. Thinking about the Web as a UI toolkit and not as a repository of useful information
    --
    Check out my cross-platform apps
  57. hard drive? by toadlife · · Score: 1

    Storage mediums are for half-wits. I keep my source code in my head. To upload and test my work, I dial up to my AOL account using my AT&T rotary phone and emulate the tones of a 28,800 baud modem using my voice.

    --
    I don't always use unix-like operating systems; but when I do, I prefer FreeBSD.
  58. Scrapbook for firefox by chuhwi · · Score: 1

    Try the scrapbook plugin for firefox. Most of the pages I've captured with it weren't too crazy, but I've never seen it fail. For example, I've used it to save pages from the new version of the amazon.com "search inside this book" feature, which is quite ajaxified.

  59. A great toolkit for AJAX is... by Toreo+asesino · · Score: 1

    Atlas for asp.net (http://atlas.asp.net/). Fantastic framework; unbelievably simple.

    I took a normal asp.net form I built for an ordering-page (lot's of postbacks for updating various basket options, etc, etc), wrapped it in an atlas XML node (all of 10 seconds work), and Bob became my uncle - the entire thing was AJAX enabled, doing lightweight postbacks & updates instead!

    And all the JS is cross-platform too - IE, FF, Safari, etc.

    And the best thing is, for all you JavaScript haters is turning off JS in the browser just meant the page automatically reverted to full-blown postbacks instead; thus not limiting accesibility.

    Oh, and I understand you can link php into Atlas too, but I'm guessing there's other stuff out there for php aswell.

    --
    throw new NoSignatureException();
  60. AJAX.NET by deuterium · · Score: 1

    I'm surprised no one has posted something about this elegent little gem. If you're an ASP.NET coder, this is a very lightweight system that allows you to treat server-side page methods as javascript-accessible. Simply add an attribute and declare it public. The framework allows you to return the usual variables (int, string, XML), as well as DataSets, ArrayLists, generic lists, DateTimes, and any class or struct composed of such. They're automatically converted into JavaScript objects via back-end JSON translation. I actually found this framework easier to work with than ATLAS. Check out the quick guide to see how simple and extensible it is.
    And it's free!

  61. No Ajax for web pages, please by jdbartlett · · Score: 1

    I hope the point the OP was trying to make was that Ajax is better suited for use in web applications than public websites.

  62. "Fry, that's the only thing about being a slave." by jdbartlett · · Score: 1

    That's the only thing about Ajax. That is, in a nutshell, Ajax.