0

I want to update some javascript variables by sending some php values through POST. Can we join both of them? My website is http://www.nattyshirts.com and i am trying to make some interactive online modules.

  • 1
    Look at this http://stackoverflow.com/questions/9925287/passing-a-php-array-into-javascript-using-json. In general, converting it to Json would be your best bett translating from server side code to something that can be used in Javascript. – StenW Jan 30 '14 at 05:33
  • possible duplicate of [How to assign Php variable value to Javascript variable?](http://stackoverflow.com/questions/5895842/how-to-assign-php-variable-value-to-javascript-variable) – Satish Sharma Jan 30 '14 at 05:36
  • i thing he made wrong titile. should be `setting up javascript variable through php` as he describe in his question content. – Satish Sharma Jan 30 '14 at 05:38

2 Answers2

0

Yes you can use ajax to communicate between client and server. Here are some examples

Bilal
  • 2,645
  • 3
  • 28
  • 40
0

try this

<?php

$your_post_value = $_POST['your_post_var']; // get post value in your php variable

?>

<script>
var your_js_var = '<?php echo $your_post_value;?>'; // set up your js variable by php variable
</script>
Satish Sharma
  • 9,547
  • 6
  • 29
  • 51