What are the benefits of Ajax?

C

Coding Monkey

It's basically done in order to save loading time of pages and offer instant feedback toward user actions. There are many, many applications of it, from simple things like clicking "Post Quick Reply" on this very thread (notice how the post appears without the page refreshing?) to full-blown applications that can act almost as desktop applications.
 
Upvote 0
Hi Steve,

Essentially, you've restated the case correctly. Normally, the only way of getting information from the user to the server is to 'post' the entire page back to the server, let it process it, then let it send an updated copy of the whole page back to the user.

This can take a little time, and causes the whole page to reload which will mean the browser may flicker and will probably scroll back to the top of the page, etc.

With AJAX, all the communication with the server can happen in the background without having to do a complete 'post-back'.

There are lots of arguments for and against. The main 'for' being it's pretty neat and allows you to do some pretty cool stuff. The main 'against' is that not all browsers support JavaScript, some people have it turned off, etc. So - if you're planning on using it, and you still want all of your site visitors to be able to use your site, you need to provide AJAX and Non-AJAX versions. This may significantly increase your development costs!
 
Upvote 0
Normally, the only way of getting information from the user to the server is to 'post' the entire page back to the server, let it process it, then let it send an updated copy of the whole page back to the user.

This can take a little time, and causes the whole page to reload which will mean the browser may flicker and will probably scroll back to the top of the page, etc.
This is exactly the issue I've faced, and I was hoping that Ajax could fix it, but...

With AJAX...The main 'against' is that not all browsers support JavaScript, some people have it turned off, etc. So - if you're planning on using it, and you still want all of your site visitors to be able to use your site, you need to provide AJAX and Non-AJAX versions. This may significantly increase your development costs!
This would be a right royal pain.

In my case, the most important reason for using it is the following. Within our application, users can scroll down the page and select various radio buttons. I want to save the settings every time a button changes, just in case the user's system crashes for whatever reason and they lose it all. Refreshing the screen takes time and it repositions the user at the top of the screen - both of which are problematic.

If we create an AJAX-only version of our site, what would be the impact on someone using a browser that does not support JavaScript? Could they still change radio buttons even though the new value would not be saved?

For this one specific feature (that applies to just one screen), could I get away with AJAX and non-AJAX versions of that single screen, or do I need separate versions of the entire application?
 
Upvote 0
Steve,

Sounds like your application would be ideally suited to AJAX as you can add it on as an added benefit.

Users with browsers that support it (and in reality, that will be most people) can get the benefit of saving as they make their choices. Your developers should be able to setup the page such that if the browser doesn't support AJAX, it simply doesn't bother to use it. In this case, their options will be saved only when they click the button at the end of the form (which shouldn't be the end of the world for the minority!?)
 
Upvote 0

dan_moore

Free Member
Mar 21, 2006
278
3
Hampshire
It's useful for elements where you want to feedback information instantly without re-loading the page. For instance on a user registration form where someone picks a username that is already taken - you can tell them instantly so they can change it there and then without having to click 'submit' and only then finding out it is taken.
 
Upvote 0
It's useful for elements where you want to feedback information instantly without re-loading the page. For instance on a user registration form where someone picks a username that is already taken - you can tell them instantly so they can change it there and then without having to click 'submit' and only then finding out it is taken.
I'm intrigued about how this scenario works. Let's say someone is typing a suggested username into a textbox. Does Ajax allow the system to compare the current string of characters with a list of all existing usernames? How does the user know there's a match?
 
Upvote 0

Astaroth

Free Member
Aug 24, 2005
3,985
278
London
Ajax simply is communication from client to server or visa versa without a full page postback. With the above scenario you simply have a on change type javascript trigger which posts back the username, and the server then has code to check the username and if it is incorrect will put a red star next to the name, for example.

The issues with it is that it is reliant on javascript (fairly minor issue as the number of people without any javascript is very small) but the main issue with it is on usability in that 1 the "page loading" animations dont trigger so if the server is slow in responding the user is unaware that the site is actually doing work and may abandon the site assuming it is broken and 2 many usability tools for partially sighted people are not compatible with Ajax
 
Upvote 0

dan_moore

Free Member
Mar 21, 2006
278
3
Hampshire
Hi Steve

The user knows there's a match because the script that the Javascript calls will return text saying "this username is currently taken" and display it alongside the username if it is taken.

Normally when the user clicks submit, the script will query the database and try to select the row with that username - if it returns a result then it means the username is taken and it tells you then.

Using Ajax all that happens is that the javascript trigger calls a script to check this when you leave the username field and returns the result there and then.

Of course with uses of Ajax that are critical to the correct functioning of a page careful coding is needed to offer an alternative for those without browser support or browser support switched off, or at least giving them a message explaining that full functionality is not available.
 
Upvote 0

Latest Articles