Javascript printing code instead of executing it when changing the contents of HTML

Javascript printing code instead of executing it when changing the contents of HTML

I am retrieving the body element of a JSON file, which is actually html code. I am trying to then add it to my HTML, but instead of running the code it prints as a p or header element(I suppose). Can any please tell me what I am doing wrong I am unable to find answers on other discussions.

I am retrieving the body element of a JSON file, which is actually html code. I am trying to then add it to my HTML, but instead of running the code it prints as a p or header element(I suppose). Can any please tell me what I am doing wrong I am unable to find answers on other discussions.

<div id="title">

</div>

<div id="body">

</div>

<script> var requestURL = 'https://secure.toronto.ca/cc_sr_v1/data/swm_waste_wizard_APR?limit=1000'; var request = new XMLHttpRequest(); request.open('GET', requestURL); request.responseType = 'json'; request.send(); request.onload = function() { var data = request.response; document.getElementById("title").innerHTML = data[0].title; document.getElementById("body").innerHTML = data[0].body; } </script>


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Create an Animated Navbar with Html, CSS and JavaScript

In this Html, CSS and JavaScript tutorial you will build an animated navbar with Html, CSS and JavaScript. Have you every wanted to create an awesome animated navbar with JavaScript? We will be looking at making a navbar with Html and CSS and then using the intersection observer in JavaScript to help us create this effect.

TIP Calculator using HTML, CSS & Javascript

We take a deep dive into how to code a tip calculator using HTML, CSS & Javascript. This tutorial can be considered as a beginner tutorial. We look into form inputs, styling form inputs in CSS & HTML while using Javascript to create the interactivity needed to calculate tips.

How Create An Accordion With HTML, CSS, JavaScript

Today we are going to create accordion with html, css and javascript