Why use a form tag when you're submitting via ajax?

前端 未结 7 882
你的背包
你的背包 2020-12-04 20:59

Philosophical question:

Say I\'ve got a web app that requires javascript and a modern browser, so progressive enhancement is not an issue. If my form is be

相关标签:
7条回答
  • 2020-12-04 21:35

    If you do not need progressive enhancement, you theoretically don't need them.

    On the other hand, forms have some cool grouping and semantic effects. Using them, you can group your form elements logically, and make it easier for your scripts to gather the values of certain elements.

    For example if you want to ajax-submit some user input, it is always easier to say: "let's take all elements in this form and submit them" than saying "let's take this input, these two selects and these three textareas and submit them". In my experience, it actually helps the developer if form tags are present.

    0 讨论(0)
提交回复
热议问题