更新时间:2023-11-27 14:56:16
正如 Jordan 已经说过的,您必须先将 javascript 变量回发到服务器,然后服务器才能处理该值.为此,您可以编写一个提交表单的 javascript 函数 - 或者您可以使用 ajax/jquery.jQuery.post
As Jordan already said you have to post back the javascript variable to your server before the server can handle the value. To do this you can either program a javascript function that submits a form - or you can use ajax / jquery. jQuery.post
也许对你来说最简单的方法是这样的
Maybe the most easiest approach for you is something like this
function myJavascriptFunction() {
var javascriptVariable = "John";
window.location.href = "myphpfile.php?name=" + javascriptVariable;
}
在您的 myphpfile.php 上,您可以在执行 javascript 后使用 $_GET['name']
.
On your myphpfile.php you can use $_GET['name']
after your javascript was executed.
问候