I'm trying to print in browser console with JS my JSON response from PHP. I saw many posts here and at another sites, but I can't do it.
I have a JSON like that
{"0":{"codigo_intervencao":"Apoio Emocional - 5270"},"1":{"tempo":"30"},"2":{"codigo_intervencao":"Apoio Emocional - 5270"},"3":{"tempo":"30"},"4":{"codigo_intervencao":"Apoio Emocional - 5270"},"5":{"tempo":"231518"},"6":{"codigo_intervencao":"Apoio Emocional - 5270"}}
I want to print in console, for example, each value of the key "codigo_intervencao", but I cannot achieve that.
I've tried something like that:
$(document).ready(function() {
  $( "#target" ).click(function() {
    console.log("Select JS");
      $.ajax({
        type: "POST",
        url: "select.php",
        dataType: 'html',
        success: function(response) {
            console.log("Response:" + response); // Here it prints above json
            var array = $.parseJSON(response);
            var tempo = 0;
            var arrayLength = array.length;
            for (var i = 0; i < arrayLength; i++) {
              console.log(array[i]['codigo_intervencao']);
        }
      });
  });
}); 
 
     
    