As the question stated above I am trying to set a variable in my javascript to be the value of the users username. This is how my code is set up:
function submitApproveModal(){
this_file = currentFile;
var approvers = "";
if(document.getElementById('approvers').checked){
approvers = '<?php $_SESSION['username'] ?>';
}
approveFileAjax(this_file.uid, approvers);
}
I know this is not the way for it to work and wondering how exactly can I rewrite my code so that approvers will equal the users username?
>Solution :
You simply forgot the "echo":
approvers = '<?php echo $_SESSION['username'] ?>';
But as mentioned before, mixing up Javascript and PHP is a bad idea.