我正在尝试使用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;
}
});
谢谢。