从Javascript变量值设置PHP变量值而不刷新[重复]

Possible Duplicate:
How to get javascript variable value in php

I am looking for help to set value of a php variable from javascript variable.

I tried these but nothing worked:

Try 1:

<script>
<?php $phpVar = ?> jVar;
</script>

Try2:

<?php $phpVar = echo "<script>document.write(jVar)</script>";

Failed too..

Please help. Please help!

Actually php is server side scripting language (that runs at server) and javascript is basically client side programming language (which runs in the browser) so you can't set a php variable from javascript. Look at these tutorials php and javascript.

But using ajax (javascript) you can pass javascript variables to php and can use them in the to the php script. Here is ajax tutorial link.