1

I have the following function on my .html page:

function Success(data)
{
var obj;
obj=JSON.parse(data);
document.write(obj);
}

that returns the objects as Hi,Hello,How,Are,You,Me,They,Them I would like to achieve the following : Like this

How do I do this?

Mistletoe
  • 347
  • 2
  • 4
  • 13
  • Stackoverflow isn't a *"how to"* tutorial service. Take a look at [Access / process (nested) objects, arrays or JSON](https://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json) – charlietfl Jul 13 '17 at 22:16

1 Answers1

0

If obj is a string then you can split it's content by ',' and generate a table as follows:

var obj;
obj=JSON.parse(data);
obj = obj.split(',')

result = '<table><tr>';
obj.forEach(function (item, i) {
  result += '<td>' + item +'</td>';
  if ((i + 1) % 4 == 0) result += '</tr><tr>';
})
result += '</tr></table>';

document.write(result);

you will probably need to style the table after.

Anthony Ngene
  • 746
  • 8
  • 12