ajax购物车
Making a simple AJAX shopping cart
制作一个简单的AJAX购物车
Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine.
几年前,我做了我的第一个购物车,我使用了iframe和JavaScript,当时那很好,没有会话或AJAX,我在客户端计算机上使用了cookie。
Today we have more advanced technology, faster, better and more fancy, we can make shopping carts on any site with no need to talk with cookies, let sessions do the storing and AJAX make the communication.
今天,我们拥有更先进的技术,更快,更好,更花哨,我们可以在任何站点上制作购物车而无需与Cookie对话,让会话进行存储,而AJAX可以进行通信。
In this tutorial I will show you how to make a Session/AJAX based shopping cart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.whizbase.com/en
在本教程中,我将向您展示如何使用WhizBase来制作基于Session / AJAX的购物车,如果您想了解有关WhizBase的更多信息,请阅读我以前的文章, 网址为http://www.whizbase.com/cn g /?p = 8
The products page
产品页面
Every shopping site have a product page, and that page is where everything starts when you make a shopping. To add products to the shopping cart we need products, every product need an Unique ID. On this page we will also show the cart, we make sure when the visitor comes for the first time it will be empty. Every visit will be a unique shopping and that means a unique session. Sessions are temporary data files created on the server having some data about or from the visitor coming on the site. Every visitor have its own unique session. WhizBase manages sessions automatically, so you just work with session variables as you work with any other, no need to work with session files on the server.
每个购物站点都有一个产品页面,购物时一切都是从该页面开始的。 要将产品添加到购物车中,我们需要产品,每个产品都需要一个唯一ID。 在此页面上,我们还将显示购物车,我们确保访客第一次来时将是空的。 每次访问都将是一次独特的购物,这意味着一次独特的会话。 会话是在服务器上创建的临时数据文件,其中包含有关访问者或来自站点的访问者的一些数据。 每个访客都有自己独特的会话。 WhizBase自动管理会话,因此您可以像处理任何其他变量一样使用会话变量,而无需使用服务器上的会话文件。
In this file which I will name as «default.