I am facing issue regarding passing javascript variables to php within same function. My code looks like this
 else if(msg_type[i] == 'code' ){
    var code_action = 'test';
    <?php
    function foobar_func(){
    return "<script>document.writeln(action[i]);</script>";
    }
    add_shortcode( 'foobar', 'foobar_func' );
    ?>
}
what i am doing is passing that code_action variable of javascript and returning it to function without using ajax or jquery...is there any possible method to do so...??
any possibilities will be appreciated. Thank you
 
    