Date Posted:
Product: TIBCO Spotfire®
Product: TIBCO Spotfire®
Problem:
How to trigger a Python script at a given time interval using JavaScript/JQuery.
Solution:
Description:
The example in this article shows how a Script Button control can be triggered at a regular interval (1 second, in this case) using JavaScript/JQuery.
The following sample JavaScript code can be used in the Text Area that contains the action control that executes your IronPython script.
==============================================
$(function() {
setInterval(
function()
{
$("#load :first-child").click();
}, 1000);
});
==============================================
Explanation:
This is the underlying example HTML for the above script:
<div id="load">
<p><SpotfireControl id="077816855b3548a78222b1f55cb30864" /></p>
</div>
<p> </p>
<p>Current Date/Time - <SpotfireControl id="ad33a7130c0a49649ef88761892da6b1" /></p>
https://api.jquery.com/category/selectors/Explanation:
- #load is the div tag which contains the python action control, i.e. the button.
- first-child is the first element in the div tag, in this case the python button.
- setinterval will call the python code every 1000 milliseconds as defined by the "1000" integer. You can set the timer (ms) based on how frequently you want to invoke the script.
This is the underlying example HTML for the above script:
<div id="load">
<p><SpotfireControl id="077816855b3548a78222b1f55cb30864" /></p>
</div>
<p> </p>
<p>Current Date/Time - <SpotfireControl id="ad33a7130c0a49649ef88761892da6b1" /></p>
Disclaimer:
The script code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the script in accordance with your implementation specifications that best suit your business requirements. Refer to the API reference(s) cited in this article for usage of the classes and methods used in the script.
Comments
0 comments
Article is closed for comments.