Answers for "output json in html"

0

how to display json data in html

function appendData(data) {
  var mainContainer = document.getElementById("myData");
  for (var i = 0; i < data.length; i++) {
    var div = document.createElement("div");
    div.innerHTML = 'Name: ' + data[i].firstName + ' ' + data[i].lastName;
    mainContainer.appendChild(div);
  }
}
Posted by: Guest on December-22-2020
0

Sending HTML Code Through JSON

$html_content="<p>hello this is sample text</p>";
$json_array=array(
'html_content'=>$html_content
);
echo json_encode($json_array);
Posted by: Guest on May-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language