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"); page.addEventListener("show", function(event){ var aleatorio = Math.floor(Math.random()*10); document.getElementById("Title").innerHTML = "Tab " + Math.floor(Math.random() * 10); document.getElementById("Content").innerHTML = "Number" + Math.floor(Math.random() * 10); });*/ var page = document.getElementById("home"); page.addEventListener("show", function(event){ var aleatorio = Math.floor(Math.random()*11); //var azar = document.getElementById("azar"); //var img = ons.createElement(``); document.getElementById("image").innerHTML = ``; document.getElementById("Title").innerHTML = data[aleatorio].Artesanias; document.getElementById("Content").innerHTML = data[aleatorio].Info; //azar.appendChild(img); }); } request.send()