Disabled fields not picked up by serializeArray

前端 未结 4 965
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 09:20

(Question updated to reflect real issue)

I just realized that serializeArray is not fetching content from disabled fields.

A set of

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 09:35

    $('#field').removeAttr('disabled');
    var formData = $(this).serializeArray();
    $('#field').attr('disabled', 'disabled');
    

    The solution above is better - alternatively you can just remove the disabled attribute from the element, serialize the fields then re-add the attribute.

提交回复
热议问题