simple jquery document ready and then I need some value from php to be alerted
for example remote address.
$(document).ready(function() {
string1="<?= $_SERVER['REMOTE_ADDR'] ?>";
alert(string1);
When I write like this result is
<?= $_SERVER['REMOTE_ADDR'] ?>
What’s wrong ? no way to pass some php inside js file ?
The file has to be run through the PHP pre-processor. This is usually done by giving the file a
.phpfile extension (although you can configure webservers so that isn’t needed).If you are serving up something that isn’t HTML, then make sure you specify the content type.