weixin_33738555 2017-05-29 14:12 采纳率: 0%
浏览 85

在Ajax中保存JS数据

My current code is:

Play.save = function() {

    //Hide the buttons
    this.printButton.visible = false;
    this.saveButton.visible = false;
    this.backButton.visible = false;

    //Force the game to re-render.
    this.game.cameras.render(); //generally not recommended if you can help it

    //Get the canvas information
    var img = this.game.stage.canvas.toDataURL("image/octet-stream");

    this.saveajax(img);

    //Show UI again.
    this.printButton.visible = false;
    this.saveButton.visible = true;
    this.backButton.visible = true;

}

Play.saveajax = function(img){
    $.ajax
    ({
        url: "http://localhost/ourthing/character/save.php",
        type: "POST",
        cache: false,
        data: {
            img: img
        }
    });
}

The file 'save.php' works (when i simply open the file). It will execute a query which it has to do. Problem here is: with this script i want to update a user with the given post data (img). But it doesnt execute on this request.

(i create data for var img and send this data to the saveajax function, which will open save.php to execute the query).

Im very new to JS/ajax. Does anyone can help me?

Best regards

  • 写回答

2条回答 默认 最新

  • elliott.david 2017-05-29 14:23
    关注

    apparently I cant comment, so my question is what are you getting on save.php with command like

    error_log(print_r($_REQUEST,true));
    

    I suspect JSON issue here. can we see save.php? Ok didn't see your previous comment, scrap that - your Jquery is not included.

    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码