What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

Time and time again I see questions from people who expect to just be able to pass JavaScript variables to PHP (and sadly it is always PHP). The asker has no understanding of client/server separation and how HTTP communication works. Is there a canonical answer on this topic that we can point people towards that explains this well?

share|improve this question
1  
I know what you mean! Part of the problem is that PHP seems to encourage mixing the client side code and server side code in the same files. Thus, people then have to wrap their head around the fact that all the stuff in the <?php ?>'s gets converted to HTML/JavaScript, or some other result before being sent to the browser. –  jmort253 Nov 16 '12 at 8:26
6  
It's not always PHP; I've seen plenty of these questions asked about ASP.NET, too. –  Andrew Barber Nov 16 '12 at 8:26
1  
@AndrewBarber - I don't hang in the ASP.NET tags, but I suspect this problem occurs with any server-side scripting language that encourages mixing the code with the client side, like JSP, for instance. Just wait until NodeJS is more widely used and in the hands of the noobs; imagine the confusion when you have to explain to people why their SSJS isn't running when they click a button. ;) –  jmort253 Nov 16 '12 at 8:27
    
@jmort253 note that ASP.NET (both WebForms and more in MVC) has client-side and server-side code in the same file too. –  AakashM Nov 16 '12 at 8:50
3  
I blame jQuery. The $ confuses them. –  Tim Post Nov 16 '12 at 9:41
3  
@TimPost I've seen this issue from plenty of people who were unaware of jQuery. I blame the socio-economics that allow people who don't understand the technologies they're using to get jobs using those technologies. –  Rushyo Nov 16 '12 at 13:35
    
@AakashM To be fair, ASP.NET MVC goes to great lengths to separate those concerns, if you're doing a lot of processing in the page, you're doing it wrong, and most people who use MVC frameworks (or any variation) are aware of this. –  casperOne Nov 16 '12 at 21:55
    
I guess the answer to my question is 'No' then. We should ask a question and answer it ourselves. Any ideas for a question that lends itself to a canonical answer? –  alnorth29 Nov 19 '12 at 16:53

You must log in to answer this question.

Browse other questions tagged .