最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MVC后臺(tái)創(chuàng)建Json(List)前臺(tái)接受并循環(huán)讀取實(shí)例

 更新時(shí)間:2013年06月09日 16:11:16   作者:  
MVC后臺(tái)創(chuàng)建Json(List)同時(shí)前臺(tái)接受并循環(huán)讀取,具體實(shí)現(xiàn)代碼如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助
---------------------------后臺(tái)-------------------
復(fù)制代碼 代碼如下:

[HttpPost]
public JsonResult CheckStock(IEnumerable<pvIdsCount> pvIds)
{
var resultList = new List<pvIdsCount>();
if (pvIds != null)
{
foreach (var pvIdsCount in pvIds)
{
var pvId = pvIdsCount.pvId;
var count = pvIdsCount.count;
var stock = _productService.GetProductVariantById(pvId).StockQuantity;
if (stock - count < 0)
{
var pvIdC=new pvIdsCount();
pvIdC.pvId = pvId;
pvIdC.count = stock;
resultList.Add(pvIdC);
}
}
if (resultList.Count > 0)
{
return Json(new { resultList }); //Json() ---MVC的JSON 方法會(huì)自動(dòng)把List<T> IEnumerable<T>轉(zhuǎn)換為 Json Array<T>
}
else
{
return Json("success");
}
}
return null;
}
public class pvIdsCount
{
public int pvId { set; get; }
public int count { set; get; }
}

---------------------------前臺(tái)-------------------
復(fù)制代碼 代碼如下:

AJAX
success: function (data) {
if (data == "success") {
}
} else {
$.each(data.resultList, function (index, value) {
$("#Item_PVId_" + value.pvId).html("This Product's Stock Not Enough.Stock is " + value.count);
});
}
}

相關(guān)文章

最新評(píng)論

罗江县| 衢州市| 松滋市| 长丰县| 同德县| 锡林郭勒盟| 信阳市| 炉霍县| 玛沁县| 石家庄市| 凌云县| 东方市| 青神县| 长顺县| 五指山市| 河东区| 南郑县| 洛川县| 贡山| 南涧| 区。| 古交市| 卓尼县| 开鲁县| 迭部县| 徐闻县| 河曲县| 安龙县| 绥中县| 宝鸡市| 郎溪县| 沙雅县| 托克逊县| 揭阳市| 铁岭市| 南昌县| 临汾市| 公安县| 元谋县| 三门县| 岳阳市|