Reputation: 4383
I need to set JavaScript variable by php variable with out ajax. I try following code:
<script type="text/javascript">
var url = <?php echo($url); ?>;
</script>
but it will make problem,How can I do it?
Upvotes: 1
Views: 7152
Reputation: 254926
Url is a string, so put it within quotes:
var url = '<?php echo($url); ?>';
Upvotes: 14