将JavaScript变量的内容传输到php变量 [英] Transfer the contents of a JavaScript variable to a php variable

查看:98
本文介绍了将JavaScript变量的内容传输到php变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将JavaScript变量的内容传输到php变量吗?

Transfer the contents of a JavaScript variable to a php variable?

推荐答案

听起来像是您正在谈论从客户端向服务器发送内容. 使用 XMLHttpRequest [
Sounds like you are talking of sending content from client to server.
Use XMLHttpRequest[^] for it.


几乎没有可用的解决方案.但最简单的示例如下所示:
few solution is available. but the simplest one would be as below example:
function forward()
{
 var a=100;
 var b=200;
 document.location="target_php_file.php?a="+a+"&b="+b;
}



现在,调用此所谓的函数.

并在php中使用



now, call this so called function.

and in php use


_GET数组访问数据.

正如我告诉您的,您还可以做其他技巧来发送数据.您可以按照Sandeep Mewara的要求发送AJAX请求,也可以使用隐藏的对象创建隐藏的表单,然后在表单上提交提交功能.好选择你的解决方案
_GET array to access the data.

as i told you can also do other trick to send the data. you can send as AJAX request as Sandeep Mewara says, you can also create hidden form with hidden object and then commit submit function on the form. well pick your solution


这篇关于将JavaScript变量的内容传输到php变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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