将javascript变量转换为php
我想把js变量传递给php将javascript变量转换为php,php,javascript,Php,Javascript,我想把js变量传递给php function sub(uid){ window.location.href='<?php echo $urlp -> certificationceap(uid) ;?>'; 功能子模块(uid){ window.location.href=''; 这里有一些问题你不能解决 浏览器发出请求 Web服务器运行PHP Web服务器向浏览器提供HTTP资源 浏览器解析HTML并执行其中的任何JS 在这个阶段,将数据发送到PHP程序
function sub(uid){
window.location.href='<?php echo $urlp -> certificationceap(uid) ;?>';
功能子模块(uid){
window.location.href='';
这里有一些问题你不能解决
function sub(uid){
location.href = 'redirect.php?uid=' + encodeURIComponent(uid);
}
检查此线程您可以使用ajax来实现这一点……如果不是有意回答,请提前道歉
function send_var(js_var_1, js_var_2){
var parms = 'js_var_1='+js_var_1+'&js_var_2='+js_var_2;
if(js_var_1!='' && js_var_1!=''){
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
//your result in xmlhttp.responseText;
}
}
xmlhttp.open("POST","<REMOTE PHP SCRIPT URL>",true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(parms);
}
}
函数发送变量(js变量1,js变量2){
var parms='js_var_1='+js_var_1+'&js_var_2='+js_var_2;
如果(js_var_1!=''&&js_var_1!=''){
if(window.XMLHttpRequest){//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
else{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
//您在xmlhttp.responseText中的结果;
}
}
open(“POST”,true);
setRequestHeader(“内容类型”,“应用程序/x-www-form-urlencoded”);
send(parms);
}
}
当然可以。用户的浏览器中没有PHP。您好,欢迎来到StackOverflow!请编辑您的问题;添加以下几点可能会得到更好的答案:1.您试图完成什么?2.您迄今为止尝试了什么?3.您得到了什么结果(不,“这里有一些问题”远远不够描述)?4.这与您期望的结果有何不同?似乎您希望将php变量传递给javascript,对吗?