如何在jquery中将数据从一个页面传递到另一个页面 [英] How to pass data from one page to another page in jquery

查看:1115
本文介绍了如何在jquery中将数据从一个页面传递到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在jquery中将值从一个页面传递到另一个页面而没有查询字符串?

I want to pass values from one page to another page without query string in jquery?

推荐答案

试想一下:JavaScript在客户端工作。一个页面如何可能知道另一个页面?您只能通过服务器端间接执行此操作。该技术使用会话状态。请从这里开始: http://msdn.microsoft.com/en- us / library / 87069683%28v = vs.80%29.aspx [ ^ ]。



一些背景:HTTP协议纯粹是无状态的。一切都发生在客户端发送的HTTP请求和服务器端返回的HTTP响应之间。除非您有一些持久对象来保留某些状态数据,否则每个请求/响应对之间的所有内容都将丢失。会话状态旨在解决此类问题,但原则上,它可能是其他问题。示例:在某些数据库中,在服务器端的文件中保留和检索状态数据等。



-SA
Just think about it: JavaScript works on client side. How one page can possibly "know" about another one? You can only do it indirectly, via the server side. The technique uses session state. Please start here: http://msdn.microsoft.com/en-us/library/87069683%28v=vs.80%29.aspx[^].

Some background: HTTP protocol is purely stateless. Everything happens between HTTP request sent from client side and HTTP response returned back by the server side. Everything in between each request/response pair is lost, unless you have some persistent object to preserve some state data. Session state is designed to resolve such problem, but in principle, it can be something else. Example: keeping and retrieving state data in some database, in files on server side, etc.

—SA


Sergey Alexandrovich Kryukov所说的是真的。但是,如果要求您在不使用查询字符串的情况下发送数据,请尝试使用cookie。由于您可以在客户端访问cookie,您可以从一个页面保留值并将其用于另一个页面。
What Sergey Alexandrovich Kryukov said is true. But if it is requirement that you want to send data without query string, try using cookies. As you can access cookies at client side, you can keep value from one page and get it for another page.


将值从一个页面传递到另一个页面(使用客户端)



1.查询字符串



page1.html?myValue = 10







2.表格提交



page1:







名字:











page2:

访问page1表单值需要任何服务器端编码





3.饼干



第1页:



创建一个有价值的饼干







第2页:



在这里访问你的page1 cookie值



4. window.name



Page 1:







window.name =数据文字去了他重新...;











Page 1















第2页:









document.write(window.name);









Page 2




passing values from one page to another page (using client side)

1. Query string

page1.html?myValue=10



2. form submit

page1 :



First name:





page2 :
Any server-side coding is needed to access the page1 form values


3. Cookies

page 1 :

Create a cookie with value here



page 2:

Access your page1 cookie value here

4. window.name

Page 1 :



window.name = "data text goes here...";





Page 1







Page 2 :




document.write(window.name);




Page 2



这篇关于如何在jquery中将数据从一个页面传递到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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