1976 Umar 1976 Umar - 4 years ago 118
PHP Question

json data not getting into html table

I am still a newbie, any help thanks

Two column json formatted data not displayed into table, i am fetching from php response

json output:

{
"success": "200",
"data": {
"id": "amit_0001sin",
"email": "xyz@email.com",
"Lastupdate": "",
"name": "amit singhal"
}
}
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();
};

Answer Source
$.each(data.data, function (key, value) {
                    $("#enqfield_show").html("<li>" + value + "</li>");
                    $("#enqfield_show").append("<li>" +key +" : "+ value + "</li>");
                });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download