In PHP programming, you can use $_POST or $_SESSION[' '] to pass parameters to the js function, or you can use the echo statement for output
I think there are two methods:
The first one: If you get the parameter value through php through the get method:
Just use js to redirect to the address of the php file:
window.location .href = 'mis/vocat/service.php?param=xx'
Second option: pass value through ajax
I use js library: jquery
If you only pass one parameter param is directly written as: param: value of param
If there are multiple parameters, it is written as: parameter 1: value of parameter 1, parameter 2: value of parameter 2
$(function(){
$. post('mis/vocat/service.php',{param:value},function(){
//The processing that js needs to do after php returns the corresponding data
});
})
What you are doing is using JS variables in PHP, which is not feasible and impossible.
First of all, you must understand that the PHP script is compiled immediately, and the compilation is completed. Only PHP can execute HTML and JavaScript.
I think your requirement does not require JavaScript. You can use get/post to pass the value of your SID. If you want no refresh, you need to Use ajax asynchronously to achieve it.
Just a moment:
You can use php variables in js, but not vice versa