Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is it appropriate to use AJAX?

Tags:

ajax

php

webforms

When is it appropriate to use AJAX?
what are the pros and cons of using AJAX?

In response to my last question: some people seemed very adamant that I should only use AJAX if the situation was appropriate: Should I add AJAX logic to my PHP classes/scripts?

In response to Chad Birch's answer: Yes, I'm referring to when developing a "standard" site that would employ AJAX for its benefits, and wouldn't be crippled by its application. Using AJAX in a way that would kill search rankings would not be acceptable. So if "keeping the site intact" requires more work, than that would be a "con".

like image 743
John B Avatar asked Dec 02 '22 08:12

John B


1 Answers

It's a pretty large subject, but you should be using AJAX to enhance the user experience, without making the site totally dependent on it. Remember that search engines and some other visitors won't be able to execute the AJAX, so if you rely on it to load your content, that will not work in your favor.

For example, you might think that it would be nice to have users visit your blog, and then have the page dynamically load the newest article(s) with AJAX once they're already there. However, when Google tries to index your blog, it's just going to get the blank site.

A good search term to find resources related to this subject is "progressive enhancement". There's plenty of good stuff out there, spend some time following the links around. Here's one to start you off:

http://www.alistapart.com/articles/progressiveenhancementwithjavascript/

like image 132
Chad Birch Avatar answered Dec 04 '22 00:12

Chad Birch