javascript - Declare variable in php file that will access in JS/jQuery -


how can declare global variable in php file , access directly in jquery?

html

<script type="text/javascript">       var date_selected = <?php echo $from; ?>; </script> 

js

$(function() {    alert("dsdsadasdas" + date_selected);    var date = date_selected;    var startdate;    var enddate; }); 

because on test not working.

you missing quotes

var date_selected = '<?php echo $a; ?>'; 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -