jQuery form serialize - empty string

前端 未结 4 1386
故里飘歌
故里飘歌 2021-01-31 12:46

My html:

 

        
4条回答
  •  遥遥无期
    2021-01-31 13:27

    You have to give the input element a name. E.g.:

    will give you in the alert box foo=2.

    .serialize() takes the name and the value of the form fields and creates a string like name1=value1&name2=value2. Without a name it cannot create such a string.

    Note that name is something different than id. Your form also would have not worked if you used it in the "normal" way. Every form field needs a name.

提交回复
热议问题