【问题标题】:Ajax method to post score achieved within Phaser game在 Phaser 游戏中发布得分的 Ajax 方法
【发布时间】:2017-03-25 06:42:59
【问题描述】:

我有一个运行良好的 Phaser 游戏。我需要将分数提交到我的服务器,该服务器有一个可以接受分数的操作。这可能吗?

【问题讨论】:

    标签: ajax phaser-framework


    【解决方案1】:

    你好,你可以试试这个:

    var my_score = 20; 
    
    function submit_score(my_score) {
        var fd = new FormData();
        fd.append("my_score", my_score);
        var xhr = new XMLHttpRequest();
    
        xhr.open('POST', 'post.php', true);
        xhr.send(fd);
    
    }
    

    这是 PHP 文件

    <?php 
    
        $score = $_POST["my_score"];
    
        echo $score;
    
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-12
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2021-09-28
      相关资源
      最近更新 更多