I have a php function that pull data from the database and return html code which is a code for a drop down menu. What I need to do is append this drop down menu to the div using jQuery. The problem that I am having is how can I assign the return value from php into a jQuery variable?
function returnUserNames(){
//open connection to the database
return 'this an html code that should be returned by this function';
}
I have tried the following but it is not working.
<script>
var menu = <?php echo returnUserNames() ?>;
$('#show_menu').append(menu);
</script>
Thanks
<?php echo returnUserNames() ?>in".