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如果更新操作 –
這是工作正常。代碼中的空警報意味着,在數據庫中最可能沒有錯誤和數據。 –