php - not able to display data in the table -
i need retrieve data mysql database using jquery. had tried both methods ($.getjson & $.ajax) none of them produced desired results.
though data coming in browser's console(netwaork tab), not displayed in table.
my php file. above code generates desired json structure when viewed in browser.
here jquery code. (using $ajax method)
$(document).ready(function() { var jsonobj = []; $.ajax({ url: "reg_data_table_js.php", success: function(data) { //alert(data) jsonobj = data; var tr; (var = 0; < jsonobj.length; i++) { tr = $('<tr/>'); tr.append($("<td>" + jsonobj[i].id + "</td>")); tr.append($("<td>" + jsonobj[i].firstname + "</td>")); tr.append($("<td>" + jsonobj[i].lastname + "</td>")); tr.append($("<td>" + jsonobj[i].email + "</td>")); tr.append($("<td>" + jsonobj[i].zipcode + "</td>")); tr.append($("<td>" + jsonobj[i].username + "</td>")); tr.append($("<td>" + jsonobj[i].password + "</td>")); tr.append($("<td>" + jsonobj[i].interest + "</td>")); tr.append($("<td>" + jsonobj[i].relocation + "</td>")); tr.append($("<td>" + jsonobj[i].position + "</td>")); tr.append($("<td>" + jsonobj[i].startdate + "</td>")); $("#jsondata tbody").append(tr); } }, error: function(err) { alert(err) } })
i think need json response array data id, firstname, etc, ...
and try @guradio said use jsonobj = data.users
hopefully helped
Comments
Post a Comment