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条)

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换