I have a .js file with only javascript in it and my question is; I have separate .php file and .js file. And I want to get the value the .php file echoes/returns. How can I fix this?
I searched around and found that I could use this:
php:
<?php
echo 'name';
?>
js:
var user_name;
$.get('getId.php', function(data) {
user_name = data;
});
// other code
But this didn't work. Or perhaps do I need another js lib included? I don't get what the php file returns, its blank.