Js:

function onAjaxSuccess(data){ console.log(data); data.forEach(function(data) { table.innerHTML += getRowTemplate(data); } ); } function getRowTemplate(userData) { return '<tr>' + '<td>' + userData.tovar + '</td>' + '<td>' + userData.type + '</td>' + '<td>' + userData.proizvoditel + '</td>' + '<td>' + userData.hvat + '</td>' + '<td>' + userData.ygol + '</td>' + '<td>' + userData.lengthc + '</td>' + '<td>' + userData.color + '</td>' + '</tr>' } 

What's wrong?

Content data:

enter image description here

  • one
    I can assume. that data is a string, and only one of two lines is needed: var results = JSON.parse(data); - Grundy
  • one
    @ bsuart2017, read my very first comment, or see the answer :) - Grundy
  • one
    @MasterAlex, because this is console.log output, and if there are line breaks in the line - it perfectly displays them - Grundy
  • one
    @ bsuart2017, insert the received text line into the question, although I already see the error - Grundy
  • 3
    You have invalid JSON in data , so you can't parse it. The comma is lengthc after the value for the lengthc field in each element of the array - Grundy

1 answer 1

 function onAjaxSuccess(data){ 

Add after this

 data = JSON.parse(data);