欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

MVC action返回partialView前台html 拼接

程序员文章站 2022-12-01 18:04:36
//后台     [HttpPost]         public Action...

//后台

 

 

[HttpPost]

        public ActionResult GetNextLazyLoadProduct(int[] productIdList)
        {
            var products = _productService.GetProductsByIds(productIdList);
            var preparedModel = PrepareProductOverviewModels(products);
            return PartialView("_LazyLoadProducts", preparedModel);

        }

 


//前台

 


var url = "@Url.Action("GetNextLazyLoadProduct")";
                    $.ajax({
                        url: url,
                        type: "POST",
                        datatype: "json",
                        contentType: "application/json",
                        data: JSON.stringify({ productIdList: array }),
                        error: function () {
                        },
                        success: function (data) { 
                            $("#lazyScrollLoading").append(data);
                            $("#lazyLoadNum").attr("value", nextLazyLoadNum);
                        }                 
                    });