【问题标题】:Codeigniter Shopping Cart with Ajax带有 Ajax 的 Codeigniter 购物车
【发布时间】:2013-04-25 07:14:26
【问题描述】:

我在使用 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>

【问题讨论】:

标签: jquery ajax codeigniter cart


【解决方案1】:

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

    <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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-26
    • 2011-12-04
    • 1970-01-01
    • 2015-07-06
    • 1970-01-01
    相关资源
    最近更新 更多