MVC中$.ajax的post问题

前端之家收集整理的这篇文章主要介绍了MVC中$.ajax的post问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
 var customerID = $("#hdn_CustomerId").val();
        $.ajax({
            async: false,type: "post",url: "/ExpressDeliveryMode/GetModel",contentType: 'application/json;charset=utf-8',data: "{'customerID':'" + customerID + "'}",success: function (msg) {
                var m = msg;
                check(m.Value,"deliveryAgree");
                check(m.Code,"ywlb");
            },error: function () {
                alert("未连接到");
            }
        });

  [HttpPost]
        public JsonResult GetModel(string customerID)
        {
            string strWhere = string.Format(" And A.CUSTOMER_ID={0}",customerID);
            List<ExpressDeliveryMode> list = iExpressDeliveryModeService.GetExpressDeliveryList(string.Empty,strWhere);
            Ywlb ywlb = new Ywlb();
            if (list != null && list.Count != 0)
            {
                foreach (ExpressDeliveryMode model in list)
                {
                    ywlb.Value += model.BUS_ID + ",";
                    ywlb.Code += model.BUS_CODE + ",";
                }
            }
            else
            {
                ywlb.Value = "";
                ywlb.Code = "";
            }
            return Json(ywlb);
        }
原文链接:https://www.f2er.com/ajax/160728.html

猜你在找的Ajax相关文章