我有一个我喜欢提交的表格jQuery
Ajax
。我的Ajax
功能类似于以下代码:
$('#submitForm').click(function (e) {
e.preventDefault();
$.ajax({
url: '/Letter/Create',
type: 'post',
data: {
letterViewModel: $('#letterForm').serialize(),
relatedLetters: JSON.stringify(relatedLetterList)
},
success: function (result) {
alert('success ' + result);
},
error: function () {
alert('error');
}
});
});
我的行动是:
[HttpPost]
public virtual ActionResult Create(LetterViewModel letterViewModel, string relatedLetters)
{
.
.
.
}
问题来了,Action
方法的第一个参数总是null
. 我不知道是什么问题,任何建议都会有所帮助。
更新:序列化后的数据:
__RequestVerificationToken=goQJDz5BCMx9NCJAZ3yuMA2E-WRgL9pJvavkLhF27epxkz3bRO_t-ADNhGHslHjXifLuxmFQcJBuOkMBSqMlFjkfKjVK-hGgY-nvRmp_2i81&CategoryId=1&LetterTitle=456&Exporter=465&ArchivePlace=456&OrgLetterNumber=456&OrgLetterDate_fa=1392%2F02%2F02&IndicatorNumber=456456&IndicatorDate_fa=1392%2F02%2F09&RelatedLetterId=3
我的LetterViewModel
:
public class LetterViewModel
{
public Int32 LetterId { get; set; }
public Int32 RelatedLetterId { get; set; }
public Int32 ServiceUserId { get; set; }
public Int32 CategoryId { get; set; }
public String LetterTitle { get; set; }
public DateTime OrgLetterDate { get; set; }
public String OrgLetterNumber { get; set; }
public DateTime IndicatorDate { get; set; }
public String IndicatorNumber { get; set; }
public String ArchivePlace { get; set; }
public Boolean HasAppendix { get; set; }
public Int32 PageCount { get; set; }
public String Exporter { get; set; }
public String OrgLetterDate_fa { get; set; }
public String IndicatorDate_fa { get; set; }
public List<CategoryViewModel> CategoryViewModels { get; set; }
public List<VwLetterViewModel> RelatedLetters { get; set; }
}