1

我有以下 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("");
    }
4

0 回答 0