I tried the following:
<script type="text/javascript>
var cdata = <?php echo json_encode($cdata); ?>;
</script>
it works fine. I'm trying to place the script in a file:
var cdata = <?php echo json_encode($cdata); ?>;
and then access it with:
<script src="crewjs.php" type="text/javascript"></script>
but that's not working. Here's the error from the console:
crew.js:186 Uncaught TypeError: Cannot read property 'ldm' of null
at monthOnly (http://www.example.com/abc/public/js/crew.js:186:15)
at HTMLButtonElement.onclick http://www.example.com/abc/public/crew.php:3021:112)
I think the clue here is Cannot read property 'ldm' of null, it's not seeing the object. The file is being found when I check sources and network
jQuery.getJSON()the file?$.getJSON(...)call to a PHP file that's spitting out valid json.