0
了解我,我可能做错了什么,但我看看如何解析数据从Javascript到PHP看起来像使用Ajax,它看起来不错,但它不想通过发送数据并更新它我的数据库。Ajax无法正确解析数据?
发生的只是一个对话框,里面没有任何东西。
AJAX:
$.ajax({
url: 'updateCredits.php',
type: 'GET',
data: {
credits: totalcash
},
success: function(data){
alert(data);
}
});
PHP:
<?php
require 'steamauth/steamauth.php';
include ('steamauth/userInfo.php');
include('mysql/config.php');
if(isset($_SESSION['steamid'], $_GET["credits"])) {
$credits = $_GET['credits'];
mysqli_query($db,"UPDATE set credits = credits + '".$credits."' WHERE steamid = '".$steamprofile['steamid']."'");
} else {
echo 'An Error has occurred, this is either due to you not being logged in or something went wrong!';
}
?>
你期望发生的?你没有在成功上回应任何事情。 另外你的代码是非常非常非常脆弱的[SQL注入](https://www.owasp.org/index.php/SQL_Injection) – ntzm
侧面说明:您应该使用PUT如果更新操作 –
这是工作正常。代码中的空警报意味着,在数据库中最可能没有错误和数据。 –