无刷新页面更新会话变量 [英] update session variable without page refresh

查看:96
本文介绍了无刷新页面更新会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更新第1页上的会话变量,当在IFRAME(外部页)点击一个链接。 会话变量设置成功,当我点击iframe的链接。 问题是我需要刷新页面1更新第1页上的会话变量。

I need to update the session variable on page 1, when click on a link in iframe (external page). session variable is successfully set when i click on iframe's link. the problem is i need to refresh the page 1 to update that session variable on page1.

如何解决this.any阿贾克斯,jQuery的帮助。 感谢

how to resolve this.any ajax , jquery help. THanks

推荐答案

HTML A HREF 链接:

<a href="#" id="clickme">Update Session</a>

jQuery的codeS:

jQuery codes:

您可以用行的数据发送数据:{varname的:在这里,我们去'}

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$("#clickme").click(function(e) {
    e.preventDefault();
    $.ajax({
        type:'POST',
        url:'update.php',
        data: { varname: 'here we go'},
        success:function(response){
           alert(response);
        }
    });
});
</script>

update.php文件:

update.php file:

您可以送送无功与 $ _ POST [varname的]

<?php
   $_SESSION["varname"] = $_POST["varname"];
   echo $_SESSION["varname"];
?>

这篇关于无刷新页面更新会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆