I'm trying to access each element stored as a Base64 image/blob in a JSON array constructed from a MySQL query.
The idea is to click a button that goes through each element and displays the image.
I have gotten it to display the first image however when i click again, the next image doesn't show.
Any help will be much appreciated.
AJAX:
   $(function () {
        $('#getimg1').on('click', function () {
             $.ajax({
            type:'GET',
            dataType: 'json',
            url: 'http://testing/api/getimg',
            success:function(getinfo){
                 $.each(getinfo, function(i, displayimg){
                $('#HTMLBox').prop('src','data:image/png;base64,' + displayimg.XXX ---- //Here I'm suspecting something?); 
                 });
            }
        }); 
    });  
    });
PHP:
 $sql = "SELECT img from artistlocation";
    try{
        $db = new db();
        $db = $db->connect(); 
        $stmt = $db->query($sql);
        $data = array();
        while($result = $stmt->fetch(PDO::FETCH_OBJ))    
        {
            $data[] = base64_encode($result->img);
        }
       echo json_encode($data);
    }
    catch(PDOException $e){
        echo '{"error": {"text": '.$e->getMessage().'}';
    }
I'm using just 2 images to test this.
 
     
    