如何在PHP文件中获取jQuery变量值 [英] How to get jQuery variable value in PHP file

查看:365
本文介绍了如何在PHP文件中获取jQuery变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在不调用ajax的情况下在同一文件中的PHP代码中使用jQuery变量值?请帮助我,这可能与否.这里的jQuery和PHP代码在下面给出.

I need to jQuery variable value in PHP code in same file with out calling ajax? Please help me it is possible or not. Here jQuery and PHP code here given below.

推荐答案

那么您可以使用jquery.session插件来存储Session变量,然后可以使用php代码访问该变量.

well you can make use of jquery.session plugin to store Session variable and then you can access that variable using php code.

示例代码

$(function() {
      $.session("myVar", "value");
});

在PHP中

echo $_SESSION['myVar'];

这篇关于如何在PHP文件中获取jQuery变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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