Is AJAX worth it?

He has: 698 posts

Joined: Jul 2005

I've been working on development for a new website recently and the biggest portion of the work is with the several forms across the website. Obviously, with AJAX pushing into the realm of forms across the internet that is one solution I have considered to speed up the process, but is it worth it?

There are a few issues I have with AJAX:

First of all, it's truly not that much faster. Sure, it can give you results without loading a new page, but the information still has to go through the same functions to be retrieved. In essence, the script is not any simpler or faster; simply the browser's loading process is ignored more.

Second of all, it adds a lot more to the backend of the website in the form of JavaScript. With AJAX, there's close to twice as much script for virtually the same effect. And more than that, because it's JavaScript, the user can easily find the source of the code in the files in use to possibly exploit any security holes. I can't think of anything right this second, but if you left a hole open, you're at a much higher risk with this method.

Lastly, it's not 100% compatible like plain PHP, ASP, etc. A server-side scripting language works globally, independent of the user's request, whereas JavaScript, and thus AJAX, can be disabled by the user. This means that if AJAX is prominent in the functionality of your website, not all of your users will be served the same experience, and once again, you have to add in extra code to support those with JavaScript disabled.

With these three points in mind I can't help but think that for a website with several hundreds to thousands of users as a possibility, is AJAX worth it? Except for little bits of a form here and there for validation, is the work really going to reap any major rewards? I guess for now I can't help but move on without it for the most part...

Kurtis

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

I have learned the fundamentals of AJAX but I have not yet been on a project requiring its use.

I do a lot of passing variables between PHP and JavaScript, in some cases it functions like AJAX without page reloads.

I agree that a lot of AJAX functions could be handled with plain JavaScript and or PHP (or maybe Lassoscript, another server-side scripting language but stay away if you can).

Like other emergent technologies, it is partly used so widely because it is a fad. (Remember those pages of JavaScript alert buttons everybody thought were cool in 1998?)

And like most technologies it has a place and a time - but maybe not necessary for your project?

I'd be interested to hear from others who actually use AJAX.

greg's picture

He has: 1,581 posts

Joined: Nov 2005

I have though about learning Js for a while now, just for it's usefulness in some areas.

Then when I discovered AJAX I felt even more strongly about learning it. Content changing on pages without re-load when users select/change things was something that appealed to me greatly. Not as a fad/play thing, but in real world convenient and practical usage.

But the reason I haven't are exactly what you put-

mscreashuns wrote:
.....And more than that, because it's JavaScript, the user can easily find the source of the code in the files in use to possibly exploit any security holes.....

A server-side scripting language works globally, independent of the user's request, whereas JavaScript, and thus AJAX, can be disabled by the user. This means that if AJAX is prominent in the functionality of your website, not all of your users will be served the same experience, and once again, you have to add in extra code to support those with JavaScript disabled.

I could manage the time to learn JS/AJAX, but I don't have the time to learn about security requirements with its code. I can't issue live any code unless I know 100% it will be secure, with PHP I know how to ensure this is done.
Equaly important is I don't have time to learn what 'exactly' the browser's "Disable JS" option renders useless within the code.

So you make a site with lovely AJAX options and a visitor with JS disabled comes along and 90% of it doesn't work at all. You might as well have had a blank page for that user.
Which, as any decent and respectable coder will do, you of course are left with serving alternatives depending on if current user has JS disabled.
And then how reliable is the determining of if user has JS disabled?

A magnificant and powerful coding language but at a click of a button, which the site coder has no control over, people can stop it working.

I know the arguement is only 2-5% (or whatever) have JS disabled, but then that arguement goes completely against the use of JS as well. Why spend days making alternatives for a handful of users? It's basically twice the work as you have to make two pages for every one page.

It's all FAR too hit-and-miss for my wanting to take it seriously.

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

JavaScript without XML is very powerful and useful

With DHTML you can change elements on the page without reloading

I have a personal site I developed over 10 years at GeoCities free hosting, which means no php no database just javascript html css - it's a good example of what can be accomplished with good ol' DHTML

[due to the large number of Opera users here, I have fixed my old script to not give an error on Opera Sticking out tongue ]

I agree with mscreashuns (gee that phrase has a familiar ring to it) that knowing AJAX adds another tool to your "belt"

He has: 698 posts

Joined: Jul 2005

I would like to say that I have learned how to work with AJAX, and it definitely is useful. If nothing else, I guess it's just another thing to add to the "What I Can Do" list...sort of. Sticking out tongue

Kurtis

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

IMO it is a lot like flash. Slowly people start to play with it, find out the cool things it can do, as they learn more, they start thinking the whole site should use it (or in the case of flash, the whole site should be a flash file), then as time goes on, they slowly back down and use flash where it is really appropriate (we at least hope they make it to this last stage).

A good example of AJAX: getting the shipping rates on an order form if you want it to be an "all in one page" order form.

-Greg

They have: 426 posts

Joined: Feb 2005

Yes i agree with Greg, I have not used Ajax but i can honestly say you can get by without it fine (its not a necessity) i think it is only to add a better user experience (like dynamic drop down boxes that can pull different data from the database depending on your choice).

Although javascript can validate forms quicker and easier on the client computer ultimately it should not be relied on because its just for user experience (the server should be doing the real checks)

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.