Is jQuery serialize () ordering of form data?

I have a series of inputs representing various forms:

<form id="myform">

    <div id="item1">
        <label> Name </label><input name="item1" type="text" value=""/>
    </div>

    <div id="item2">
        <label> Name </label><input name="item2" type="text" value=""/>
    </div>

    <div id="item3">
        <label> Name </label><input name="item3" type="text" value=""/>
    </div>
</form>

<script>
     $.post("/url/", $("#myform").serialize(), function(){});
</script>

When a message occurs, is it guaranteed that I will receive the data that it represents on the form? I tested it and it returned item1, item2, item3 in that order, but can this be assumed?

+4
source share
3 answers

This is a difficult question. The documentationserialize says nothing about order, but says:

... creates a text string in standard encoding with URL encoding.

RFC for this RFC 1867 notation , states:

, , .

jQuery (v1.2.1) (v1.11.0) .

, , , jQuery , " URL" RFC , . ( , jQuery ), , .

+4

, API - , , , , .

, , , , , , . , , , ( 6 ) , , , , , , ( "" )

+2

. - , post- [0], [1] .

+1

Source: https://habr.com/ru/post/1529895/


All Articles