dqf98772 2018-06-20 11:00
浏览 52
已采纳

如何使用php会话变量传递jquery变量

 <div class="wrap-input100 validate-input bg1 rs1-wrap-input100">
                <div class="contact100-form-btn" id="add_driver">
                <span>
                Add another Driver
                <i class="fa fa-long-arrow-right m-l-7" aria-hidden="true"></i>
                </span>
                </div>
            </div> 


<script>    
 var count = 0;
 jQuery("#add_driver").click(function(){
 count++;
 }); </script>

how can i pass the value of the variable count to the next page using php sessions or any other method? is there any simple way to do it?

  • 写回答

2条回答 默认 最新

  • dousendun8411 2018-06-20 11:16
    关注

    Using Below code you can send count value to secondpage.php and in second page use $_POST['count_var'] to access variable. You can check your success response in success: function (response)

    <script>    
     var count = 0;
     jQuery("#add_driver").click(function(){
     count++;
     $.ajax({
                            type: 'post',
                            url: 'secondpage.php',
                            data: {
                                count_var: count,
    
                            },
                            success: function (response) {
                                 document.getElementById("divid").innerHTML = response;
                            }
                        });
     }); 
    
     </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料