dongtai419309 2013-07-29 05:23
浏览 51
已采纳

如何在php中的更改事件上的文本框上设置Session变量

I want to update my session variables on textbox's onchange event, without page reload How to do that.?? thanks!

  • 写回答

4条回答 默认 最新

  • dongwei1921 2013-07-29 05:35
    关注

    I would use on blur, that way it wont set the variable everytime the user types, only when he clicks somewhere else....

    $('textbox').blur(function(){
      var thevalue = $(this).val();
    
     $.ajax({
        url:'yoururl.php',
        type: "post",
        data:{"value":thevalue},
        dataType:"html",
        success:function(data){
            console.log(data);
        } 
     });
    });
    

    THen in your php...

    <?php
       $_SESSION['yoursessionkey'] = $_POST['value'];
       echo "success";
    

    ?>

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?