What is better to return to ajax: html data or json?
I have in my php(mvc) controller PostController where i have metod index. That method return array with all users posts,comments, post likes, comment likes, etc. It is a large merged array! Somthing like on facebook wall!
All that i render in view/home/index.php file with php and with jquery ajax i load that file in specific div
But looking fb and other social network sites they return json object.
In my case if i return json_encode json to ajax i must loop with each all posts and commets.
So if i loop with $.each i must put to much html codes inside $.each.
It is not ugly and bad practice to put all that html code inside javascript looping? Or exist better solution for this loop?