javascript - how to pass js integer value as integer in PHP? -


this question has answer here:

<script type="text/javascript">     var int_val = 111; </script>  <?php     $js_int_val_in_php ='<script>document.write(int_val);</script>';     echo $js_int_val_in_php; // 111     echo '<br>';     echo gettype($js_int_val_in_php); // string       // want integer     // settype(); not help!! ?> 

anyone has idea how pass js integer value integer in php?? love jquery in situation, please no jquery suggestion.

you confusing server-side variables client-side variables,

you need data server, otherwise server knows variable name, string

<script> var int_val=111; function doajax() { var xmlhttp; xmlhttp=new xmlhttprequest(); xmlhttp.open("get","index.php?v="+int_val,true); xmlhttp.send(); } </script> <a href="javascript:doajax();">click here send data server</a> <?php $int_val='' if (isset($_get['v'])) {$int_val=intval($_get['v']);} //now can access `int_val` after js function ran ?> 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -