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

前端 未结 7 930
你的背包
你的背包 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:15

    Not that I can see. I'm currently building a web application that uses

    s, but I'm using them so I have a fallback method if the user has JavaScript disabled (an e.preventDefault stops the form posting normally). For your situation, where you're saying the user MUST have JavaScript, a tag isn't necessary, but it might be an idea to keep it anyway in case browser need to do anything with it, or to access it as a sort of class.

    In short, no, you don't need to use if you're doing pure AJAX, although leaving it in might an idea if you suddenly decide to create fallback code in the future.

提交回复
热议问题