var warp1_data = {
"id": "warp1",
"x": 371,
"y": 95,
"images": 'map/town/balamb.png',
"framerate": 32,
"animations":
{
"down": [0, 3, "down", 0.25],
"left": [4, 7, "left", 0.25],
"right": [8, 11, "right", 0.25],
"up": [12, 15, "up", 0.25],
"downLeft": [16, 19, "downLeft", 0.25],
"downRight": [20, 23, "downRight", 0.25],
"upLeft": [24, 27, "upLeft", 0.25],
"upRight": [28, 31, "upRight", 0.25]
},
"frames":
{
"height": 32,
"width":32,
"regX": 0,
"regY": 0,
"count": 32
},
"movement":
{
"type" : '8dir',
"distanceOnPress" : 4,
"keycodeUp" : -1,
"keycodeDown" : -1,
"keycodeLeft" : -1,
"keycodeRight" : -1
},
"collisionObject": true,
"collisionType": "pixel",
"collisionAlphaThreshold": 10,
"onCollision": function() {
//only allow the collision text once every 5 seconds
if (!window.playerCollisionTxt) {
window.playerCollisionTxt = true;
setTimeout(function(){ window.playerCollisionTxt = false; }, 5000);
$.ajax({
url: "update_loc.php",
type: "GET",
data: { 'username': user, 'liked': '1' },
success: function()
{
alert("ok");
}
});
location.reload();
}
}
};
这段代码有问题吗?我已将此添加到我的HTML中:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
我想要的只是将JavaScript AJAX连接到SQL数据库。
无论如何,我正在使用深渊网络服务器最新版本&amp;这是我的PHP文件:
<?php
include "config.php";
$get_move_loc_1 = mysql_query("SELECT * FROM ".$CONFIG['database'].".login WHERE userid='".$_SESSION['ff_account']."' LIMIT 1");
$get_move_loc_2 = mysql_fetch_array($get_move_loc_1);
$get_move_loc_3 = mysql_query("SELECT * FROM ".$CONFIG['database'].".char WHERE account_id='".$get_move_loc_2['account_id']."' LIMIT 1");
$get_move_loc_4 = mysql_fetch_array($get_move_loc_3);
$char_id = $get_move_loc_4['char_id'];
mysql_query("UPDATE ".$CONFIG['database'].".char SET last_map='Balamb Garden' WHERE char_id='$char_id'");
mysql_query("UPDATE ".$CONFIG['database'].".char SET map_x='371' WHERE char_id='$char_id'");
mysql_query("UPDATE ".$CONFIG['database'].".char SET map_y='115' WHERE char_id='$char_id'");
&GT;
答案 0 :(得分:0)
update_loc.php
则没问题。location.reload();
重新加载页面。我认为这会让你感到困惑。删除它就是全部。