Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is one way I can classify websites:

a) those that reload on every little matter - you add a comment-they reload, the live score updates-they reload the whole page, instead of just the score..

b) some like these websites do not reload when there is no need, like adding a comment, etc.

I find the second ones convenient, I guess everyone does. So why does not everyone make websites like that?

Technically, where does the difference lie among the two types I mentioned??

share|improve this question
The reason you don't see more of the second types of websites is because it's harder to do, and requires more work. However, with tools that make this all super easy (like jQuery), expect more websites to take advantage of Ajax in the coming years. Almost every "new" website that I've been to has used it. – Sasha Chedygov Sep 15 '09 at 22:32
up vote 2 down vote accepted

Technically, where does the difference lie among the two types I mentioned??

While AJAX is the common reason these days, the core of the answer is client-side scripting. After all, AJAX is nothing more than client-side scripting and there's plenty of other ways to make changes to and update a webpage without the need of a refresh. (See DOM in seanyboy reply).

Websites that provide scripts that run on the client machine (JavaScript being a common technology) allow for content to be processed and changed without the need for a server roundtrip. On the other hand, Server-side scripting (such as languages like PHP) are processed on the server, hence the need for a reload. The request is sent to the server, it is processed there and the new page sent back to the client where it is "refreshed".

share|improve this answer
"Websites that provide scripts that run on the client machine (JavaScript being a common technology) allow for content to be processed and changed without the need for a server roundtrip." but suppose I add a comment on , then there has to be a server roundtrip because the comment has to be communicated to the server?? – Lazer Sep 16 '09 at 6:14
Definitely. And for that you have been using a client-side scripting while employing a technique called AJAX :) OTOH, if you want to click the comment button and a comment field to expand without having to reload the page, you use client-side scripting, but you don't need to employ the AJAX technique. So, at the core of your ability is the nature of the scripti language. Client-side scripting allows for such things. – A Dwarf Sep 16 '09 at 11:25

Sites like SuperUser use a technique called AJAX it stands for Asynchronous JavaScript And XML. This means that they can update parts of a web page without reloading the entire page. This is what the other sites do. Sites using AJAX should be quicker as they don't have to send all the data for the page every time something changes.

Wikipedia has an article which is probably a good starting point, but there are lots of resources out on the web.

share|improve this answer
I like your answer best so far, so am gonna add to it via comments, instead of adding my own answer... – Roy Rico Sep 15 '09 at 22:29
I think it's important to mention that AJAX techniques provide a lot of functionality for normal users, but also present some drawbacks to users who need a website to be available to the handicapped (known as accessibly in web development terms). Many fun sites can provide an AJAX interface, without worrying about accessibly. However sites that are more serious (banks, utilities) need to provide accessibility, so in order to create the nice AJAX functionality they'd have to do twice the work, so many companies dont find it cost effective. (tho there's some disagreement about that) – Roy Rico Sep 15 '09 at 22:37
Another reason sites don't use AJAX could be because the site was created before many AJAX techniques became mainstream, or the current developers are not familiar with AJAX techniques (or their management has't approved them to upgrade) – Roy Rico Sep 15 '09 at 22:38
Remember that the X in AJAX stands for JSON – Sam Hasler Sep 18 '09 at 19:11

AJAX programming allows you to update elements of the page dynamically. However, AJAX has a number of disadvantages over just displaying the webpage. These include:

  • They're harder to program. It's a lot tougher to do AJAX programming, and as a consequence, people will avoid it unless they have to.
  • They have "Client Side" and "Server Side Code". As well as writing code on the server side to display the page, you also have to write code that runs on the browser (Internet Explorer, etc) to do the dynamic updates. This takes longer, and is more difficult to get your head around.
  • Browser Standards. Certain web browsers (like the afore mentioned Internet Explorer) behave differently to the defined standards and other web browsers (like firefox). Older browsers may not work with AJAX at all. Mobile browsers (on your phone) may also not work with AJAX, or they may work with a subset of AJAX. Because of this, it may be better to make your web pages in a way that works across all browsers and not use AJAX.
  • AJAX is still pretty new. Because of this, a lot of programmers don't know how to create dynamic web pages. Also - older web pages / websites won't have AJAX in them. Finally, there is currently a lack of training and documentation with regard to the AJAX way of doing things.

I feel like some of these points may overlap, and some of the points I've made may be slightly contentious. I've also avoided talking about the DOM. However - I think I've got the basics.

DOM: Document Object Model. Loosely put, it defines how an AJAX program finds the place on the page to put/change the new element (e.g. a comment). Again, the DOM and how you access it differs from browser to browser. When you hear people moaning about what a bad browser IE6 is, it's because access to it's DOM is (a) broken (b) hard to use and (c) different to every other browser out there.

share|improve this answer
(+1) for DOM. Indeed you can talk about it. It's at the core of client-side scripting. – A Dwarf Sep 15 '09 at 23:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .