Alex Rivera | Logout

Is Form Tag Necessary in AJAX Web Application?

Asked 2010-04-24T14:14:58.913
16

I read some AJAX-Form tutorial like this. The tag form is used in HTML code. However, I believed that it is not necessary. Since we send HTTP request through XmlHttpRequest, the sent data can be anything, not necessary input in form.

So, is there any reason to have form tag in HTML for AJAX application?

Edit
Report

1 Answer

6

Apart from progressive enhancement as already discussed (don't make your site require JavaScript until it really has to), a <form> with onsubmit would be necessary to reliably catch an Enter keypress submission.

(Sure, you can try trapping keypresses on separate form fields, but it's fiddly, fragile and will never 100% reproduce the browser's native behaviour over what constitutes a form submission.)

answered 2010-04-24T15:01:26.773

Your Answer