How can I get form data with JavaScript/jQuery?

前端 未结 28 2328
不知归路
不知归路 2020-11-22 12:39

Is there a simple, one-line way to get the data of a form as it would be if it was to be submitted in the classic HTML-only way?

For example:



        
28条回答
  •  再見小時候
    2020-11-22 13:24

    var formData = new FormData($('#form-id'));
    params   = $('#form-id').serializeArray();
    
    $.each(params, function(i, val) {
        formData.append(val.name, val.value);
    });
    

提交回复
热议问题