Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
646 B
2
Indexable
Never
let movie = new XMLHttpRequest();

movie.onreadystatechange = function () {
    if (movie.readyState == 4 && movie.status == 200) {
        let data = JSON.parse(this.responseText);
        console.log(data);
        data.forEach(function (data) {
            let daftar = document.getElementById('list-movie');
            daftar.insertAdjacentHTML('beforeend', `<div class=" card-body">
                        <h5 class="card-title">`+ data.title + `</h5>
                        <p class="card-text">Tahun : `+ data.year + `</p>
                    </div>`);
        });
    }
};

movie.open('GET', 'json/script_2.json', true);
movie.send();v