Access a JavaScript variable from PHP

后端 未结 8 953
萌比男神i
萌比男神i 2020-11-22 11:47

I need to access a JavaScript variable with PHP. Here\'s a stripped-down version of the code I\'m currently trying, which isn\'t working:

相关标签:
8条回答
  • 2020-11-22 12:11

    JS ist browser-based, PHP is server-based. You have to generate some browser-based request/signal to get the data from the JS into the PHP. Take a look into Ajax.

    0 讨论(0)
  • 2020-11-22 12:14

    I'm looking at this and thinking, if you can only get variables into php in a form, why not just make a form and put a hidden input in the thing so it doesn't show on screen, and then put the value from your javascript into the hidden input and POST that into the php? It would sure be a lot less hassle than some of this other stuff right?

    0 讨论(0)
提交回复
热议问题