Codeigniter与Ajax的购物车

时间:2013-04-25 07:14:27

标签: jquery ajax codeigniter cart

我遇到了Ajax和CodeIgniter购物车的问题。没有AJAX,代码运行良好。好像我无法发帖。

<script type="text/javascript">
    $('ul.products form').submit(function(){

      $('#noticeMessages').empty(); 
        var id = $(this).find('input[name=id]').val();  

  $.ajax({
          type: 'post',
          url:'../books/addProduct',
          data:{id:id}
          }).done(function(data){

              $('#noticeMessages').append('Your product has been added').css('visibility','visible').fadeIn('fast').fadeOut(5000);
              location.reload();

          });
          return false;
    });
</script>

1 个答案:

答案 0 :(得分:0)

虽然这似乎是一个死的问题,但我仍然觉得提出我的建议。这就是我要做的事情

    <script type="text/javascript">
        $('ul.products form').submit(function(){

          $('#noticeMessages').empty(); 
           var id = $(this).find('input[name=id]').val();  
          $.ajax({
              type: 'post',
              url:'../books/addProduct',
              data:{id:id},
              success:function(data){
                $('#noticeMessages').append('Your product has been added').css('visibility','visible').fadeIn('fast').fadeOut(5000);
                  location.reload();
              }
             });
        });
    </script