Passing a Javascript string to PHP

后端 未结 4 952
傲寒
傲寒 2021-01-20 08:21

i want to pass a javascript string to php ... WHICH is RIGHT after the code .. in the script.



        
4条回答
  •  渐次进展
    2021-01-20 08:25

    You should get the difference between client side and server side code clear. The variable you are introducing in the php code isn't assigned before because that variable is set at the client. So your code example is in essence wrong. If you want a value that is present at the client (javascript) to be available at the server (php), you need to do something with the xmlhttprequest object of javascript (also know as ajax).

    You can do the other way around though...print a php value in javascript. This is because the script is than created server side and send to the client before it is being processed by the browser.

    Not sure what you are trying to reach but maybe this helps a bit.

提交回复
热议问题