Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I know this is a frequent question on Stack Overflow but I couldn't find scenario where the PHP code is just above JS script in the same file. I guess ajax POST/GET won't do the job in this case?

(...)
var ww = $(window).width();
   </script>

<?php $ww = [data here] ?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
253 views
Welcome To Ask or Share your Answers For Others

1 Answer

You will have to use POST/GET to send a JS variable to PHP, because PHP is processed by the server and JS is processed by the client.

I know this isn't what you want to hear.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...