views:

56

answers:

4

I'm trying to understand when I should use asynchronous web calls back to the server for data in an ajax app.

I've never used ajax before so I'm still stuck with my idea of the stateful model of HTTP, having used it that way for over a decade.

In a blog engine I'm writing as an ajax exercise, I'd like to add some asynchronous calls.

What would be an appropriate place to do this for blog-type features?

A: 

Submit comments is an obvious choice.

Jarrett Meyer
A: 

From the perspective of the blog author, previewing posts is a great opportunity for AJAX. I wrote that into my own blog engine (unfortunately it doesn't always work :-P but I'm sure you can do better). Previewing/submitting comments is another possibility. Slashdot has a nice system, though theirs might be overkill unless your blog gets a lot of comments.

David Zaslavsky
+1  A: 

Comments are a good place for making an AJAX call. When a user is adding a comment, they likely don't want to have to wait for the entire page to reload to see their comment added. A much better method would be do use an AJAX call to insert the comment into the database, and dynamically add their comment's content to the page.

bcwood
in a blog I used it for search results as well. When user searches I got and list all found blog posts titles, when you click title it expands the whole blog post. Quite useful stuff.
dr. evil
Yes, I've seen something similar done in a couple of places, and it looked pretty slick. But like many things, overuse of AJAX can be quite annoying and/or confusing to the user.
bcwood
+1  A: 

I'd say; everything that would normally make you refresh the page.

But (more) seriously; I think that stackoverflow is a great (!) example of what background calls can do for you. I especially like to be notified, while typing my comment, when another user just commented.

Also, you could scrape some relevant blog posts from other blogs (perhaps use google, or something) and show that to the blogger, while he is typing his blog (also, kind of what stackoverflow does). This way, he will also learn a thing or two from others, while typing up his own thoughts.

And of course the obvious image uploading and preview stuff..

MiRAGe
+1 for image uploading, reminds me that I should put that in my own blog too...
David Zaslavsky