我想从PHP文件传递变量的值,以将其用作JavaScript函数的参数。 E.g:
PHP:
$passed = "passed";
$failed = "failed";
$name = $_POST['name'];
if($name == "lekz"){
echo $passed; // this variable will pass to js file
}
else{
echo $failed; // this variable will pass to js file
}
JS:
function trace(){
var con = "passed"
if($passed == con){
alert("passed");
}
else{
alert("failed");
}
}
我能以什么方式将变量从PHP传递到JS函数?