在jQuery中存储从PHP文件中拾取的数据 [英] storing data picked up from php file in jquery

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

问题描述

我有一个运行简单的jquery脚本的php文件:

I have a php file that runs a simple jquery script:

var text = $(".hide").text(); 

我想知道当我重定向到其他页面时如何存储这些数据

I was wondering how I could store this data when I redirect to other pages

推荐答案

您可以将其放入 a Cookie .编写它,离开页面,然后在进入下一页时阅读您自己的cookie.

You could put it into a cookie. Write it, leave the page, then read your own cookie when you get to the next page.

或者您可以将其发布到另一个PHP脚本中,并将其存储在会话变量中.在jQuery中,看起来像这样

Or you could POST it to another PHP script, and store it in a session variable. In jQuery, it would look something like this

$.post("my_other_script.php", { text: "my piece of text"} );

my_other_script.php将是

my_other_script.php would be

<?php $_SESSION['text'] = $_POST['text']; ?>

这是 jquery页面文档.

这篇关于在jQuery中存储从PHP文件中拾取的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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