I am trying to include an echo from a php file to javascript file.
I have this code in my php-file:
<?php
...I connect and load list from database here...
for($i=0;$i<sizeOf($list_rows);$i++) {
echo '"'.$list_rows[$i]['name'].'": null,';
}
?>
and the following code in my JavaScript file:
<script>
$('input.autocomplete').autocomplete({
data: {
HERE I WANT TO HAVE THE ECHO
},
});
</script>
The php-file is giving me the correct echo when I open it directly, but my javascript file don't. Can you help me?