AJAX is wonderful technology that we often use in Dynamo’s backend. For example, consider the following typical scenario: You are editing a post and you want to associate it to a category that doesn’t exist yet. The pre-AJAX solution would probably require you to browse away from what you are doing, find the “Add Category” form, add the category, find the post you were editing before and select it. Now, you can click the “Add Category” button which is in the categories side-bar right there on the edit post form, fill in the name, click add and then select the newly created category without leaving or reloading the “edit post” screen. We have similar functionality around associated images and files: While writing a post or editing a page you can simply upload a file and use it straight away.
I feel that these are great usability improvements, because they certainly cut down on annoyances or time spent doing typical tasks, but that doesn’t mean you should start using AJAX everywhere.
At first we wanted to make the entire posts section one big AJAXified monster that never reloads. You would go to the manage posts screen, see the list of posts, click on one, the post listing would slide out of view, the post edit form would fade in, you would make your changes, it would fade out, the listing would slide back in…
Hold on. What do you do if you just want to send someone a link to edit a specific post? How do you bookmark the post edit form to get back to it later? What happens when you’re editing a post, you want to go back to the listing and you click the browser’s back button? Or you clicked around, different blocks of things loaded in and faded out and now you hit refresh?
I think you must be cautious when using AJAX with operations that “switch context”. Some REST-like principles are probably relevant here: each resource should have its own unique URL. If something is contained entirely within another page (like Dynamo’s comments, associated files and categories), then I think it is usually OK to break with this.
In Dynamo, associated files are usually edited or displayed in a lightbox in the admin interface, post comments go on the post edit screen and post categories are on the post listing or post edit screen. Because of this, I don’t think the user will expect direct links to them. When you load them in they don’t replace other content on the screen, therefore the user will not think of clicking the back button to go to that previous state that really is part of the same page.
I think formally defining when to use AJAX and when not is quite difficult. You’ll just have to use your head and think about how the user will interact with your application.
Leave a Response