Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php和会话的jquery购物车_Php_Jquery_Session_Cart_Shopping - Fatal编程技术网

使用php和会话的jquery购物车

使用php和会话的jquery购物车,php,jquery,session,cart,shopping,Php,Jquery,Session,Cart,Shopping,你好 我现在通过创建一个基本的购物车来学习这个jquery,在jquery中添加到购物车按钮、删除项目和清除按钮都起作用 该函数用于保存会话中添加的项,还可以通过jquery删除和清除。现在我对jquery如何添加项有了一个想法。但不是移除单个项目或清除购物车上的所有项目 任何帮助、建议都将不胜感激 谢谢…:D 这是我到目前为止在购物车上完成的代码。这是在两个文件中,index.php和cart.php是“添加到购物车”按钮,除了“删除”和“清除”之外,其他按钮都已在工作。因为我还不能运行会话

你好

我现在通过创建一个基本的购物车来学习这个jquery,在jquery中添加到购物车按钮、删除项目和清除按钮都起作用

该函数用于保存会话中添加的项,还可以通过jquery删除和清除。现在我对jquery如何添加项有了一个想法。但不是移除单个项目或清除购物车上的所有项目

任何帮助、建议都将不胜感激

谢谢…:D

这是我到目前为止在购物车上完成的代码。这是在两个文件中,index.php和cart.php是“添加到购物车”按钮,除了“删除”和“清除”之外,其他按钮都已在工作。因为我还不能运行会话

这是:

<script type="text/javascript">
// for ajax 
$(document).ready(function(){

  $(".add").click(function(){

    var id = $(this).attr("proid");
    var item = $("#item"+id).val();
    var brand = $("#brand"+id).val();   
    var price = $("#price"+id).val();   
    var quantity = $("#quantity"+id).val();         

    $.ajax({ 
      type: "POST",
      url: "cart.php",
      data: "id="+ id + "& item="+ item + "& brand="+ brand +"& price="+ price +"& quantity="+ quantity,
      success: function(data){
        $("#jcart").html(data);
      }
    }); //ajax

    return false;

  }); //click function

  //show empty table
  $("#jcart").load("jcart.php");

  //--> for options
  $(".remove").click(function(){

    var id = $(this).attr("proid");

    $.ajax({
      type: "POST",
      url: "clear.php",
      data: "id="+ id,
      success: function(data){
        $('#jcart').html(data)
      }
    });

  });       

  $(".clear").click(function(){

    $.ajax({
      type: "POST",
      url: "clear.php",
      success: function(data){
        $("#jcart").html(data)
      }
    });

  });

});

</script>

//对于ajax
$(文档).ready(函数(){
$(“.add”)。单击(函数(){
var id=$(this.attr(“proid”);
var item=$(“#item”+id).val();
var brand=$(“#brand”+id).val();
var price=$(“#price”+id).val();
变量数量=$(“#数量”+id).val();
$.ajax({
类型:“POST”,
url:“cart.php”,
数据:“id=“+id+”&item=“+item+”&brand=“+brand+”&price=“+price+”&quantity=“+quantity,
成功:功能(数据){
$(“#jcart”).html(数据);
}
});//ajax
返回false;
});//单击函数
//显示空表
$(“#jcart”).load(“jcart.php”);
//-->选择
$(“.remove”)。单击(函数(){
var id=$(this.attr(“proid”);
$.ajax({
类型:“POST”,
url:“clear.php”,
数据:“id=”+id,
成功:功能(数据){
$('#jcart').html(数据)
}
});
});       
$(“.clear”)。单击(函数(){
$.ajax({
类型:“POST”,
url:“clear.php”,
成功:功能(数据){
$(“#jcart”).html(数据)
}
});
});
});
我在讨论如何保存然后检索项目时遇到了困难。任何想法或帮助都将不胜感激


提前谢谢

有相当多的教程可以创建(听起来像)您想要的内容

读一读它们,连同,看看你能想出什么。如果你开始了,然后陷入困境,回来,问更多的问题(带有示例和代码示例),我们将尽我们所能提供帮助