function checkCart(id, account){ if(account == ""){ alert("請先登入會員"); window.location.href = "login01.php"; }else{ var showReturnMsg = "已將商品加入購物車"; $.ajax({ type: "POST", url: "ajax/insert_cart.php", data: { 'id': id, }, dataType: "json", cache: false, success: function(data) { if(data['status'] == "true"){ alert(showReturnMsg); location.reload(); }else{ alert(data['error']); } } }); } }