Problem with swapping image with jQuery

0

Well it's like this, I have the following code:

<script type="text/javascript">
    document.addEventListener("keydown", keyDownPress, false);
    var valoresDigitados = [];

    function keyDownPress(e) {
      var keyCode = e.keyCode;
      valoresDigitados.push(String.fromCharCode(keyCode));
    }
    setInterval(function(){
    var codigos = valoresDigitados.join("");


    $.getJSON('pclock.php?codigo='+codigos, function(arrayinfo) {

    if(arrayinfo[0] != ""){

        console.log(arrayinfo[0]);
        var foto = arrayinfo[0];
    $("#foto").attr("src", foto); 

    }
    });

    }, 3000);
    </script>

The variable photo is extracted through a php document, in which ajax requests to know the value, which by default the value returned is "0.jpg", however my script is not exchanging the photo of the my page for the photo "0.jpg".

What would be the problem?

    
asked by anonymous 24.10.2018 / 02:54

0 answers