How do I pass variables and data from JavaScript to PHP? code example
Example 1: javascript access php variable
//passing PHP variable to JavaScript
var myJSVar = <?php echo json_encode($myPHPVar); ?>;
Example 2: php pass a variabele to js
<script>
'var name = <?php echo json_encode($name); ?>;
</script>'