I have written php code to generate json data, Now We have to display this json data into table. My php code is able to generate data but not able able to insert into ta
This is a way to work this with JavaScript
function fetchData1(){
$(".data-contacts1-js tbody").empty();
$.get("http://localhost/service/newJobs.php", function(data) {
data=JSON.parse(data); //if the server returns text instead JSON object
for(var i in data){
var tr=$(" ");
tr.append("" + data[i].cust_name + " " +
"" + data[i].cust_mobile + " " +
"" + data[i].cust_email + " " +
"" + data[i].cust_address + " ");
$(".data-contacts1-js tbody").append(tr);
}
});
}
$(document).ready(function(){
$(".data-contacts1-js tbody").empty();
$('#fetchContacts1').click(function() {
fetchData1();
});
});
On server script (php) add in first row
header('Content-type: application/json');