Assume AJAX

Assume AJAX.

If you are writing a web application, and you hope for it to be popular, assume AJAX. You will add it at some point. And you know what? You’re going to be duplicating a lot of server-side code in JavaScript.

Let’s start with validation. Server-side validation is a must, client-side validation is crucial for a good user experince. Next comes the typical “query from DB” presentation style (and it does not matter if it’s google serch result of facebook friend feed): a list of things, all alike. You’ll want to be able to refresh those in real-time. Another case for code duplication. If AJAX is going to show up anyway, wouldn’t we want to make it easier and with less duplicate bugs?

Well, there is one obvious solution. Have it all in AJAX. Send over static HTML files, and fill up the content with AJAX. Do the validation in AJAX, and send in remote calls (the remote calls will hopefully just have exceptions if the values are not the right type). Have stuff in JSON-RPC or something RESTful, and let AJAX do the heavy lifting. In the future, that might be an option.

But if you care about user experience, you don’t want to do that. It would take way too long for the user to get the initial approximation, compared to a traditional solution. The best of all worlds would be a server that just did the AJAX for you. It would be completely untrusted, and would serve HTML by getting the static file and running the same AJAX code being run from the client. All it would take is just another load event (say, OnServerLoad) which would be for the server. You would want a fairly compatible “browser” as the basis for the server. Perhaps one which knew how to do separation between processes well?

Yep, server-side chromium with a few API tweaks would be the perfect template engine. Put it, and your actual running-code-accessing-privileged-stuff *-RPC/REST server behind a simple squid reverse proxy with appropriate rules, have the AJAX do the calls to the backend, and you have an AJAX-ready application with your JavaScript framework of choice baked right in.

(Addendum: Jaxer seems to be close, but still no cigar)

Advertisements

One Response to Assume AJAX

  1. […] did not need that much catering to?” Once answer, unsurprisingly, is the heavy use of AJAX. In fact, advice for mobile web application writers is (from the same Grimoire): …there are […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: