douju5062 2012-07-24 04:44
浏览 25

PHP活动源 - 类似于Facebook - 如何将响应从json转换为HTML元素

We are building a activity stream kind of website very similar to facebook (in activity feed alone). For loading user's activity feed, we send the request to PHP file through AJAX method. Server file will handle the logic and return back the values as an array in JSON format. I wanted to know, is there any framework available to write the JSON response to HTML elements. Also, the fees are not similar. It will vary according to the type (Photo, Album, Status Updated, Shared, Liked, etc). So i need to load different template view for each of the activity feed. Actions will be common like Share, Comments for all feeds.

Can you please share which will be the best approach to load the content according to the data received. Also the content need to be refreshed periodically. I have pasted the sample JSON response below for reference:

{
  "id": "1",   
  "picture": "", 
  "link": "http://www.google.com", 
  "name": "Srini updated status", 
  "description": "Lorem ipsum",   
  "actions": [
    {
      "name": "Share", 
      "link": "http://networkedblogs.com/hGWk3?a=share"
    }
  ], 
  "type": "statusupdate",   
  "created_time": "2011-05-10T18:35:38+0000", 
  "updated_time": "2012-07-20T10:42:58+0000", 
  "likes": {    
    "count": 0
  }, 
  "comments": {
    "data": [
      {
        "id": "19292868552_10150189643478553_22286888", 
        "from": {
          "name": "Lorenzo Portillo", 
          "id": "613727863"
        }, 
        "message": "does anyone knows why i get a rhombus and '?' in my app     description when I publish in a user's wall, instead of a letter with accent?!?!?!?!?!?", 
        "created_time": "2012-05-28T13:48:45+0000"
      }, 
    "count": 1
  }
}

Need help / suggestions on how to design the template according to the json array in javascript. Any comments / code help will be more helpful.

Thanks in Advance,

Regards

Srinivasan.C

  • 写回答

2条回答 默认 最新

  • doukuangxiu1621 2012-07-24 04:49
    关注

    Well, if you consider making a very robust app, take a good look at emberjs.

    You should also try jquery's (jquery mobile, jquery ui, jquery ajax)

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作