dslk6326846
2015-08-12 06:58
浏览 99
已采纳

在div中以表格形式打印从php接收的json数据

I am receiving data in JSON format for name & email by $.ajax() jquery function. I need to put this data in tabular format in a div ('#div1'). I am unable to do this. Can someone help?

JSON received:

[{"jname":"Charles","jemail":"charles@gmail.com"},{"jname":"Bollen","jemail":"bollen@gmail.com"},{"jname":"Sita","jemail":"sita@gmail.com"},{"jname":"Lita","jemail":"lita@gmail.com"},{"jname":"Azma","jemail":"azma@gmail.com"},{"jname":"Robert","jemail":"robert@gmail.com"},{"jname":"Charu","jemail":"charu@gmail.com"}]

jQuery Ajax Code:

$.ajax({
    type: "POST",
    url: "retrieve.php",
    data: jQuery("#form1").serialize(),
    cache: false,
    success:  function(data){
       $('#div1').html(data);
    }
});

Please, help. I need to print this data in tabular form in a div for Name & Email.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题