dsztc99732 2012-03-21 07:44
浏览 45
已采纳

从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!

  • 写回答

1条回答 默认 最新

  • doulian5857 2012-03-21 07:57
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 用51单片机控制急停。
  • ¥15 孟德尔随机化结果不一致
  • ¥15 在使用pyecharts时出现问题
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用