views:

210

answers:

4

There are many ways to handle forms. one is to simply submit the form and the get variables on php and another one that i'm thinking of, is to send data with ajax and during this process we can show a dialog and show the information about processing the data with a progress bar.

despite the fact that ajax is faster than the standard technique and sometimes it's easier to use why there's a very few websites that are using the ajax method ?

A: 

It's not that you shouldn't be using ajax to post forms, is that you have to "double" your work (for small amounts of double). I usually make a form work with normal submit, and then I override it with javascript. That way you have a non-javascript fall-back, and don't leave anyone behind. Also lok at jQuery's $.post and $('#myform').serialize methods.

There is no intrinsic reason that it isn't used more. It's just that for most websites, AJAX isn't really needed.

voyager
A: 

AJAX is not necessarily faster, it's not necessarily easier to use, and not all visitors will be able to use it at all (in particular those who have disabled JavaScript for some or all websites). It's also not always possible to reliably show a progress bar for the AJAX submission any more than it is for a traditional submission. Finally, since the server-side code will look about the same regardless of which client-side submission method you use, submitting via AJAX is more effort, which is not always justified.

That's not to suggest that AJAX is a poor technology, or that it should be avoided. However, even forms that have the option to submit via AJAX should also support traditional submissions. After that, which forms you choose to enable AJAX submissions for should depend on where you have the budget (or, if it's a pet project, the time) to do the extra work.

VoteyDisciple
A: 

AJAX is a relatively new technology, and I'm sure in some applications is difficult to implement. If you're doing down the road of adding AJAX to your application consider Progressive Enhancement.

Andy Gaskell
A: 

Javascript, as a language, should be treated primarily as an 'addon'. Your page should work perfectly without using Javascript, AJAX, or any other browser languages.

What should ideally happen, is when you Javascript loads, it puts in an event catcher that when the form is submitted, it returns false and instead submits it using AJAX. If Javascript is not enabled, nothing every submits false, and the form is submitted server side.

This allows the most compatability, and is the reason people discourage having a lot of Javascript in the actual tags like this:

Go

Some people turn off Javascript, and some old browser might have errors with that onClick event. Heck, people might develop new browsers that omit Javascript completely for one reason or another.

The Point is that Javascript should simply be an 'addon' to the web page, not the heart of it. (Unless it is a Javascript Application, which does absolutely everything through Javascript. Normal forms however are not Javascript Applications)

Chacha102
Thank you for the answer... right now I'm thinking of implementing both.
EBAGHAKI