ajax前端代码:
$("#addShopCart").click(function(){
const shopCart = new Object();
//没有value值,获取它的text值
//thymeleaf直接赋值给js变量,就不需要getElementById()来间接获取。
shopCart.shopctGoodsId = $("#goodsId").val();
shopCart.shopctUserId = 101;
shopCart.shopctGoodsNum = $("#addIpt").val();
shopCart.shopctUpdateTime=new Date();
$.ajax({
url: "/shopCart",
type: "post",
data: {
shopCart:JSON.stringify(shopCart),
},
dataType:"text",//返回值的类型,
async: true,
success: function s(data) {
window.location.href="/sss";
},