Is is possible to use a javascript var in some php code? I want to grab the url of an attachment image in wordpress. This is currently what I have tried using.
<div id="image"></div>
<script>
var attachmentid = '8723';
var attachmenturl = '<?php echo wp_get_attachment_url('+attachmentid+'); ?>';
$('#image').append(attachmenturl);
</script>