问题遇到的现象和发生背景 :实现加入购物车,后台如何获取到数量一值,在servlet中获取该值
//加入购物车操作
var buyAccount;
$("#add_cart").click(function (e) {
//数量取值
buyAccount = $("#buy-num").val();
console.log(buyAccount);
var params = {
count: buyAccount,
product: <%=book.getIsbn()%>
};
alert(document.getElementById("buy-num").value);
$.ajax({
type: "post",
url: "${pageContext.request.contextPath}/servlet/CartServlet",
data: "uid=<%=user.getPhone()%>&isbn=<%=book.getIsbn()%>",
success: function (data) {
if (data == 'yes') {
alert("添加购物车成功!");
window.location.href = "${pageContext.request.contextPath}/servlet/CartServlet?isbn=<%=book.getIsbn()%>?count=document.getElementById("buy-num").value";
} else {
alert("添加购物车失败!");
}
},
error: function (data) {
alert("系统异常!");
}
});