var request = new XMLHttpRequest() request.open('GET', 'json/azar.json', true) request.onload = function() { // begin accessing JSON data here var data = JSON.parse(this.response) var page = document.getElementById("home"); var aleatorio = Math.floor(Math.random()*32); document.getElementById("image").innerHTML = ``; document.getElementById("Content").innerHTML = data[aleatorio].Renglones + "
" + data[aleatorio].Artesano + "
" + data[aleatorio].Municipio; page.addEventListener("show", function(event){ document.getElementById("image").innerHTML=''; document.getElementById("Content").innerHTML=''; var aleatorio = Math.floor(Math.random()*32); //var azar = document.getElementById("azar"); //var img = ons.createElement(``); document.getElementById("image").innerHTML = ``; //document.getElementById("Title").innerHTML = data[aleatorio].Renglones; document.getElementById("Content").innerHTML = data[aleatorio].Renglones + "
" + data[aleatorio].Artesano + "
" + data[aleatorio].Municipio; //azar.appendChild(img); }); } request.send()