Jasbin Karki
Jasbin Karki

Reputation: 614

How to generate table from incoming JSON data [Laravel, Ajax]

I have a controller as PostsController and an Ajax which gets JSON data from the PostsController and I am able to show that JSON data in the table in blade view, but problem is I have to statically declare the table column name and I want to make the table column name and field defined dynamically according to received JSON data.

The structure of the data is as follows:

[
  'title': 'stackoverflow is awesome', 
  'body': 'stackoverflow is the top community for developers'
]

Now here I am trying to generate table column names and show these incoming data. What I am doing right now is just generating column rows like this:

enter image description here

I would really appreciate any help.

Upvotes: 1

Views: 386

Answers (1)

Khawlah Elshah
Khawlah Elshah

Reputation: 144

Please have a look at this answer, I think it is the same as what you are trying to do.

Upvotes: 2

Related Questions