how to assign javascript variable value to php variable

前端 未结 8 1537
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 15:12

I have declared a javascript variable ,

 var myJavascriptVar = 12345;

And unable to assign that value to php variable;

相关标签:
8条回答
  • 2020-11-28 16:00

    I guess you can use cookies for it.

    1) First add a cookie jquery plugin.

    2) Then store that window width in a cookie variable.

    3) Access your cookie in PHP like $_COOKIE['variable name'].

    http://www.w3schools.com/php/php_cookies.asp

    0 讨论(0)
  • 2020-11-28 16:05

    Javascript will be interpreted in Client's browser and you can not assign it to PHP variable which is interpreted on SERVER .

    Feasible Solution : You can submit the Javascript value via ajax or through form submit.

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