用javascript提交php变量(链接?) [英] submit php variables with javascript (link?)
问题描述
我正在创建一个基于浏览器的游戏,目前正在设计脚本,当他/她单击地图的不同部分时,该角色会更新角色的位置.
I'm creating a browser based game and at the moment I'm designing the script that updates the position of my character when he/she clicks on a different part of the map.
我正在使用一些ajax来执行此操作,这会将请求发送到名为position_update.php的php文件.但是要使其正常工作,我需要随其发送两个值,以便它知道新职位是什么,我该怎么做?下面是将请求发送到php文件的链接.
I am using a bit of ajax to do this which send a request to a php file called position_update.php. But for it to work I need to send two values along with it so it knows what the new position is, how do I do this? Below is my link that send the request to php file.
<a onClick="positionUpdate();"><img src="images/transparent.gif" border="0" /></a>
请注意,我使用PHP $ _GET super global检索发送时的值.
As a note, I'm using the php $_GET super global to retrieve the values when they're sent.
谢谢,斯坦尼
推荐答案
您需要点击以下网址:
position_update.php?var1=val1&var2=val2
PHP会将获取字符串解析为$ _GET
PHP will parse the get string into $_GET
这篇关于用javascript提交php变量(链接?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!