What is the expected order of an array submitted in an HTML form?

前端 未结 4 1302
南笙
南笙 2020-12-20 13:41

I\'m wondering if there is any sort of guarantee on the order of POST variables I will see on the server side.

My use case is I have a form that a user will fill out

4条回答
  •  隐瞒了意图╮
    2020-12-20 14:08

    As Vaidas Zilionis said, data will appear in exact the same order as they appear in the form, see the W3C's HTML 4.01 Specification:

    application/x-www-form-urlencoded
    [...] 2. The control names/values are listed in the order they appear in the document.

    multipart/form-data
    [...] A "multipart/form-data" message contains a series of parts, each representing a successful control. The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream.

提交回复
热议问题