[英]JSON data not getting into HTML table
I am fetching JSON from a PHP response. 我正在从PHP响应中获取JSON。 The JSON data is:
JSON数据为:
{
"success": "200",
"data": {
"id": "amit_0001sin",
"email": "xyz@email.com",
"Lastupdate": "",
"name": "amit singhal"
}
}
The JSON should be displayed in a two-column HTML table, but it is not displayed. JSON应该显示在两列HTML表中,但不显示。
The JavaScript code for fetching the JSON and displaying it is: 用于获取JSON并显示它的JavaScript代码是:
function loadstats() {
var search_stat= $('#enq_field').val();
if(search_stat !=""){
$.ajax({
url: "dom.php",
type: "POST",
success: function (data) {
$("#enqfield_show").html("");
$.each(data, function (key, value) {
$("#enqfield_show").html("<li>" + value + "</li>");
$("#enqfield_show").append("<li>" +key +" : "+ value + "</li>");
});
$("#enqfield_show").append( "<br/>");
},
error: function (data) {
alert("ERROR: ");
for(var key in data) {
$('#enqfield_show').append(key);
$('#enqfield_show').append('=' + data[key] + '<br />');
}
}
});
} else {
$('#enqfield_show').append('<h1>something wrong</h1>');
}
evt.preventDefault();
};
What am I doing wrong? 我究竟做错了什么? Any help is appreciated.
任何帮助表示赞赏。
$.each(data.data, function (key, value) {
$("#enqfield_show").html("<li>" + value + "</li>");
$("#enqfield_show").append("<li>" +key +" : "+ value + "</li>");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.