Reputation: 1593
I need to pass the version no to javascript from php. But i dont want to use ajax.
$(document).ready(function(){
init();
})
<body>
...
<input type="hidden" id="version" value="<?php echo $version; ?>
....
<script>
function init() {
version = $('#version').val();
}
</script>
Can i do in this way? Or, should i use ajax?
Upvotes: 0
Views: 41
Reputation: 138267
If you do so theres no need to put it into a hidden input:
const version = "<?php echo $version; ?>";
Upvotes: 3