如何将javascript变量的值分配给同一页面中的PHP变量

如何将javascript变量的值分配给同一页面中的PHP变量,javascript,php,html,jquery,Javascript,Php,Html,Jquery,有一个代码,在一个页面中获取客户的值,并将其作为javascript变量发布到PHP文件中,但我无法从该页面将该变量转换为PHP变量 Index.php document.getElementById(“zoomingchart”).src=“zoomingchart.php?Customername=“+customer+”&EnvironmentType=BA”; zoomingchart.php 函数getParamValue(paramName) { var url=window.l

有一个代码,在一个页面中获取客户的值,并将其作为javascript变量发布到PHP文件中,但我无法从该页面将该变量转换为PHP变量

Index.php

document.getElementById(“zoomingchart”).src=“zoomingchart.php?Customername=“+customer+”&EnvironmentType=BA”;
zoomingchart.php


函数getParamValue(paramName)
{
var url=window.location.search.substring(1);
var qArray=url.split('&');//获取键值对
对于(变量i=0;i
在zoomingchart.php中,当我给出
console.log()
时,它会打印环境变量和Customername的值,但当我将其传递给php变量时,它会在此行中显示null或给出错误

document.getElementById("zoomingchart").src ="zoomingchart.php?Customername="+customer+"&EnvironmentType=QA";
我收到了这个错误: **

  • 得到 http://localhost/Sreesha/zoomingchart.php?Customername=MDS&EnvironmentType=BA 500(内部服务器错误)
**

在Index.php中联机:

document.getElementById(“zoomingchart”).src=“zoomingchart.php?Customername=“+customer+”&EnvironmentType=BA”;

而不是console.log您是否尝试了var\u dump($CustomerName)并看到了结果?您应该打印所有$\u GET,然后知道您得到了什么:
print\r($\u GET)
不清楚index.php与其他代码的关系。我也尝试了@jerson,甚至我尝试了@mihnsen而不是console.log。您是否尝试了var_dump($CustomerName)并看到了结果?您应该打印所有$\u GET,然后您知道您得到了什么:
print_r($\u GET)目前还不清楚index.php与其他代码的关系。我也在@jerson尝试过这个,甚至在@mihnsen尝试过