数组中的FormData推送项

时间:2019-01-22 08:14:12

标签: javascript jquery asp.net-mvc odata form-data

我正在尝试使用FormData获取列表中的值,但列表始终为null

public List<OptionAns> Answerlst { get; set; }
var formData = $('#submitform').serializeArray();

$('#customFields .optionAns').each(function (index) {
  formData.append("Answerlst[" + index + "].Id", $(this).attr('id'));
  formData.append("Answerlst[" + index + "].Value", $(this).val());
});

$("#submitform").validate({
  submitHandler: function (form) {
    var params = $.extend({}, doAjax_params_default);
    params['url'] = BaseUrl + 'odata/Questions';
    params['requestType'] = "POST";
    params['data'] = formData;
    params['successCallbackFunction'] = ajaxSuccess;
    params['errorCallBackFunction'] = ajaxError;
    doAjax(params);
    return false;
  }
});

谢谢。

0 个答案:

没有答案