views:

52

answers:

3

Hi everyone,

We're in the first steps of what will be a AJAX-based webapp where information and generated HTML will be sent backwards and forwards with the help of JSON/POST techniques.

We're able to get the data out quickly without putting to much load on the database with the help of a cache-layer that features memcached as well as disc-based cache. Besides that - what's essential to have in mind when designing AJAX heavy webapps?

Thanks a lot,

+1  A: 

Security for one. JavaScript has a pretty notoriously bad security profile.

Pierreten
+1  A: 

These are the two that always get me:

  1. What happens when the user clicks multiple items that may trigger multiple requests that may return out of order?

  2. What happens when a request doesn't come back for one reason or another (timeout, server problem, etc.)? It always happens eventually, and the more gracefully your system fails the better.

Gabriel Hurley
+3  A: 

Probably the best thing to have in mind is that your app shouldn't be AJAX-based. It should work fine if the user's browser has scripts disabled. Only then should you start layering on AJAX. Stackoverflow is a great example of this. AJAX really improves the experience but it works when it's disabled.

Another thing I like to do is to use the same PHP validation functions for both server-side and client-side validation (as in sending an AJAX request to a script containing the same PHP function) to keep the amount of cross-language code duplication to a minimum.

Read up on Degradable AJAX.

Lotus Notes
Hi Byron, Great link you'd got there. But seriously, how many users today doesn't have javascript support? I mean, those users are even more medieval than IE6 users!
Industrial
Yeah, pretty much everyone supports JavaScript. However, as Gabriel said in an answer down below, a lot of times the AJAX request simply doesn't go through. Even the big AJAX giants like facebook have this problem. It's always a mystery. But if your app is completely AJAX-based you should have some sort of fallback for when it times out.
Lotus Notes
+1 for recommending a progressive enhancement approach. The vast majority of sites out there that use AJAX don't actually *need* AJAX. AJAX just makes it *better*. Unless you're building the next Google Docs, make sure what you're doing starts with the simplest case and builds from there.
Gabriel Hurley