does DOM order determine the order of form parameters posted?

前端 未结 1 729
醉话见心
醉话见心 2020-12-19 11:19

If I have a form like this:

相关标签:
1条回答
  • 2020-12-19 11:55

    This is the standard. I find that the W3C specification is very useful and readable.

    application/x-www-form-urlencoded...

    The control names/values are listed in the order they appear in the document.

    multipart/form-data...

    The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream.

    I have yet to encounter a browser that doesn't follow this convention, so I'd say you're pretty safe to use it.

    That being said, my semantic bone is a bit uncomfortable with relying on this convention. If ordering is crucial, I would instead use:

    <form>
      <input name="param[0]" />
      <input name="param[1]" />
      <input name="param[2]" />
    </form>
    
    0 讨论(0)
提交回复
热议问题