将数据从JavaScript发送到PHP [英] send data from JavaScript to PHP

查看:83
本文介绍了将数据从JavaScript发送到PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

我有一个php页面和php方式我通过以下代码获取信息:

$ link = $ _SERVER ['HTTP_REFERER'];

但现在我想用document.referrer获取此信息,然后发送到php。

我不知道如何将此信息发送到php。



最好的问候

Dear Sir,
I have a php page and with php way I get the information with below code:
$link = $_SERVER['HTTP_REFERER'];
and but now I want get this information with "document.referrer" and then send to php.
I don't know how i can send this information to php.

Best Regards

推荐答案

link =


_SERVER [ 'HTTP_REFERER'];

但现在我想用document.referrer获取此信息然后发送到php。

我不知道我怎么发送这个信息到php。



最好的问候
_SERVER['HTTP_REFERER'];
and but now I want get this information with "document.referrer" and then send to php.
I don't know how i can send this information to php.

Best Regards


我假设你是指Web浏览器中的JavaScript。由于to PHP表示服务器端,您需要向其发送HTTP请求,这是通过AJAX完成的: http ://en.wikipedia.org/wiki/Ajax_%28programming%29 [ ^ ]。



使用AJAX的一种便捷方式是jQuery .ajax()

http://api.jquery.com/jquery.ajax [ ^ ]。



-SA
I assume you mean JavaScript in a Web browser. As "to PHP" means server-side, you need to send HTTP request to it, which is done via AJAX: http://en.wikipedia.org/wiki/Ajax_%28programming%29[^].

One of the convenient ways of using AJAX would be jQuery .ajax():
http://api.jquery.com/jquery.ajax[^].

—SA


这篇关于将数据从JavaScript发送到PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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