怎么将JavaScript中的数据传给PHP

WBOY
Release: 2016-06-13 12:53:33
Original
1489 people have browsed it

如何将JavaScript中的数据传给PHP?
现状是这样的:
使用新浪API实现登陆之后会调用JS的回调函数:

<br />
function login(o) {<br />
<br />
}<br />
 
Copy after login


传的参数o就是用户信息的JSON,现在我想取出这个数据在前端显示,
但是PHP是后台执行的, 所以我想用window.location.href跳转到另一个PHP页面,
同时传参,问题是如何将这个o传给那个PHP页面?

不知道使用form是否可行?有没有常用方法推荐


------解决方案--------------------
参照:
http://stackoverflow.com/questions/2367979/pass-post-data-with-window-location-href
不可以POST。
只有将参数设置到window.location.href URL里,相当于GET,但是GET有字数长度限制,另外使URL很丑陋。
当然还有一个方法,用COOKIE。不过COOKIE在许多国家有很多的法律限制。
------解决方案--------------------
引用:
为什么不能POST、感觉POST蛮好。

解释不清,所以引用了stackoverflow的问答,那可是全球性的问答论坛,高手如云。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!