我正在尝试用 ajax 调用替换表单提交。该操作需要 formcollection,我不想创建新模型。所以我需要通过 ajax 调用传递整个表单(就像表单提交一样)。我尝试序列化并使用 Json,但 formcollection 为空。这是我的动作签名:
public ActionResult CompleteRegisteration(FormCollection formCollection)
这是我的提交按钮点击:
var form = $("#onlineform").serialize();
$.ajax({
url: "/Register/CompleteRegisteration",
datatype: 'json',
data: JSON.stringify(form),
contentType: "application/json; charset=utf-8",
success: function (data) {
if (data.result == "Error") {
alert(data.message);
}
}
});
现在如何将数据传递到 formcollection?