我有以下Ajax调用。我有2个参数。一个是序列化形式,另一个是字符串。当我只返回表单时,所有值都存在于控制器对象中。但是,当我传递序列化表单和字符串时,填充字符串,而表单对象为空...
不确定为什么会这样。任何帮助将不胜感激。
Jquery的
function SubmitQuoteForm() {
var selectedServices = MapServiceForm();
var addressForm = $("#ShipmentForm").serialize();
$.ajax({
data: { addressModel: addressForm, serviceListing: selectedServices },
type: "POST",
url: "Home/PrepareRateRequest",
success: function (response) {
//omitted for brevity
}
});
function MapServiceForm() {
var selectedServices = $("#ShipmentForm input[type='checkbox']:checked").map(function () {
return this.id;
}).get().join('|');
return selectedServices;
}
}
控制器
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult PrepareRateRequest(Models.ShipmentModel addressModel, string serviceListing)
{
//omitted for brevity
return Json("");
}