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.

3
  • 1
    Look at this stackoverflow.com/questions/9925287/…. In general, converting it to Json would be your best bett translating from server side code to something that can be used in Javascript. Commented Jan 30, 2014 at 5:33
  • possible duplicate of How to assign Php variable value to Javascript variable? Commented Jan 30, 2014 at 5:36
  • i thing he made wrong titile. should be setting up javascript variable through php as he describe in his question content. Commented Jan 30, 2014 at 5:38

2 Answers 2

0

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

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.