追加后的AJAX PHP请求

I have a drawing canvas where the drawing saves to the directory and a url saves to the database.

When the drawing is submitted, the canvas will dissapear and the drawing will load with its likes and comments.

So far, I have created a hidden form element which contains the url of the uploaded file as well as a new function which selects the image from the database, however I am receiving no alerts to ensure this works. When looking on the console, it says "200".

How would I go about making this possible?

function doodleSave() {
    
    var canvas = document.getElementById("doodle-canvas");
    var canvasData = canvas.toDataURL("image/png");

    $.post('test.php', {data: canvasData}, function (response) {
        
        var data = JSON.parse(response);
        
        if (data.filename !== false) {
            
            $('#doodle').slideToggle();
            $('#doodle-tools').fadeToggle();
            
                var content = '<input type="text" value="'+data.filename+'" id="doodle-load-value-holder"/>';
                
            $("#main-feed").prepend(content);
            
            var canvas = document.getElementById('doodle-canvas');
            var context = canvas.getContext('2d');
            context.clearRect(0, 0, canvas.width, canvas.height);
            
            doodleLoad();

        } else {
            
            alert('unable to upload');
            
        }
    });
    
    
    
}


function doodleLoad() {
    
    var imagelocation = document.getElementById("doodle-load-value-holder");
    
    $.post('doodle-load.php', {data: imagelocation}, function (load) {  
        
        var data = JSON.parse(load);
        
        if (data.filename !== false) {
            
            
            alert('yes');
            

        } else {
            
            alert('unable to upload');
            
        }

        
        
    });
           
}
<?php

$img = $_POST['data'];

require_once 'php/connect.php';
    
    try
    {
        $stmt = $pdo->prepare("SELECT * FROM posts WHERE (image_url= :image_url)");
        $stmt->execute(array(":image_url",$img));
        $fileExist = $stmt->rowCount();
        if($fileExist != 0)
        {

            echo json_encode(['filename' => "true"]);
        }
        else
        {
            echo json_encode(['filename' => "not in database"]);
        }
    }
    catch(PDOException $e)
    {
        $return_data = $e->getMessage();
    }
    exit();

?>

</div>