Reputation: 9
All, I apologize for the simplicity of this question in advance, I'm new to programming. I have two functions, each prompts a url to load. I would like to use a timer loop to have these two functions run once every 30 seconds, and then repeat the loop. In the code below, the URL loads once, but never initializes the second URL. Thank you very much for assisting me with this question!
function initializeViz1() {
var placeholderDiv = document.getElementById("tableauViz1");
var url1 = "https://public.tableausoftware.com/views/SCADA_SERVER_DASHBOARD/Dashboard1?:embed=y&:display_count=no";
var options = {
width: 2000,
height: 1200,
hideTabs: true,
hideToolbar: false,
onFirstInteractive: function () {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
viz = new tableauSoftware.Viz(placeholderDiv, url1, options);
}
function initializeViz() {
var placeholderDiv = document.getElementById("tableauViz");
var url2 = "https://public.tableausoftware.com/views/Book1_1719/Sheet1?%3AshowVizHome=no#1";
var options = {
width: 2000,
height: 1200,
hideTabs: true,
hideToolbar: false,
onFirstInteractive: function () {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
viz = new tableauSoftware.Viz(placeholderDiv, url2, options);
}
var counter = 0;
var i = setInterval(function () {
// do your thing
if (counter === 0) {
$(initializeViz);
} else if (counter === 1) {
$(initializeViz1);
}
counter++;
if (counter === 2) {
clearInterval(i);
}
}, 15000);
Upvotes: 0
Views: 105
Reputation: 157
You can use setTimeout() like this
function testFunction(){
//do your thing
setTimeout(testFunction, 30000);
}
testFunction();
Related post here: Call a javascript function every 5 seconds continuously
Upvotes: 1