简体   繁体   English

如何在 c# 中使用 Webmethod 和 Ajax 创建购物车?

[英]How to create a shopping cart using Webmethod and Ajax in c#?

I want to create a shopping cart in that the products would be fetched from database.我想创建一个购物车,其中产品将从数据库中获取。 I would create a web method but need to call this webmethod using ajax.我将创建一个 web 方法,但需要使用 ajax 调用此 Web 方法。

How to refresh the cart on the same page whenever new item is added using ajax?每当使用 ajax 添加新商品时,如何在同一页面上刷新购物车?

You will need to initialise your shopping cart at load time您需要在加载时初始化您的购物车

let shoppingCart = []; // array of objects

First define what information you want to store in it that will be the attributes of your cart item object for instance: id, quantity, lable, price, sum start from that and give us feed back首先定义您要在其中存储哪些信息,这些信息将成为您的购物车项目 object 的属性,例如:id、数量、标签、价格、总和从那里开始并给我们反馈

then we'll help you further那么我们将进一步帮助您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM