Ajax没有正确解析数据?

时间:2017-10-17 18:59:17

标签: javascript php ajax

了解我,我可能做错了什么,但我正在研究如何使用ajax将数据从Javascript解析为PHP看起来很好但它看起来不错,但它并不想发送数据通过并在我的数据库中更新它。

所有发生的事情都是一个内部没有任何内容的对话框。

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!';

}

?>

1 个答案:

答案 0 :(得分:0)

成功时,您没有从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']."'"); 
echo 'Success fully updated';
} else { echo 'An Error has occurred, this is either due to you not being logged in or something went wrong!'; } ?>