在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

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.

Answer:

I had to include jQuery:

<script src="assets/js/jquery.js" ></script >

Thanks @Don'tVoteMeDown and @Lixus

Save.php file:

$db = framework::getDBO();

    $data = array(
        'canvas_character' => $_POST['img'],
    );

    $db->where('id', 1);
    $db->update('ot_users', $data);

(i use my own framework)