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.

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

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号