From the php file I transfer an array. enter image description here

In the function I output the passed array enter image description here

On page displays as an array enter image description here , and when accessing (alert (response [0])) does not show the value of the element. How correctly to access the array element?

    1 answer 1

    ... echo json_encode($error); ?> ... dataType: 'json', // !!! ... success: function(response) { console.log(typeof response, response); } 
    • As soon as I add the json format to DataType, the success function does not work. In my case, the error function is triggered - Sergey Sushko
    • they wrote to you that the php-part should have JSON-encode the answer - sterx
    • Sorry, I missed it. Everything works, thank you. The question is closed. - Sergey Sushko