Originally posted by Paul Yule:
Okay, I have never used Ajax...should be fun. Couple architectural questions before I go on my rampant Google search for Ajax and it's uses.
I recommend: read
this article to get an idea of how Ajax works, and then adopt jQuery to do your Ajax for you. It's madness at this stage of the game to code Ajax by hand. (You could also explore other libraries such as Prototype or Dojo, but I think the jQuery Ajax implementation is the easiest.)
In such a scenario:
1) You would submit the form via Ajax rather than as a usual submission. The jQuery Forms plugin makes this as easy as: $('#myForm').ajaxSubmit();
2) A callback that youd pass to the ajaxSubmit() method will be called when the request finishes.
3) While the surly request is taking its sweet time, your page is free to do anything it wants. It can just let the user go about his/her business. It can put up an indication that something's going on. Images such as
are popular. it can put up a "gray screen" to prevent activity. It can put up a progress bar (complicated if you want it to represent real-world progress, but possible). And so on...
4) When the callback is activated, you can grab the response data and do whatever you want. Usually this adjusts the current page with the new data. But it can just as easily redirect to a new page if desired.
[ July 18, 2008: Message edited by: Bear Bibeault ]