In that case, I would recommend putting your "handleResults" function in an tag near the top of your file.
You can then have a button or an that calls the functions in your .
Your handler can run through the returned JSON object for the rundown and put them in parameters you can see on screen.
Here is a fairly simple example of how you would interact with the JSON object:
<abs contexttype="opengear">
<meta>
<params>
<param access="1" constrainttype="INT_NULL" name="Rundown ID" oid="params.RundownID" precision="0" stateless="true" type="INT16_ARRAY" value="-1" widget="default"/>
<param access="1" maxlength="0" name="Title" oid="params.Title" precision="0" stateless="true" type="STRING_ARRAY" value=" " widget="default">
<value> </value>
</param>
<param access="1" constrainttype="STRING_CHOICE" name="Table" oid="params.table" precision="0" stateless="true" type="INT16" value="-1" widget="table">
<constraint>params.RundownID</constraint>
<constraint>params.Title</constraint>
</param>
</params>
</meta>
<meta>
<api immediate="true">function handleResults(resultData)
{
if (resultData == null)
{
ogscript.debug("NO DATA");
}
else
{
var resultsAsObject = JSON.parse(resultData);
var ids = [];
var titles = [];
for (var i = 0; i < resultsAsObject.length; i++)
{
ids.push(resultsAsObject[i]["RundownID"]);
titles.push(resultsAsObject[i]["Title"]);
}
//We need to make sure we always have at least one element in a parameter
if (ids.length == 0)
{
ids.push("");
titles.push("");
}
params.setAllValues('params.RundownID', ids);
params.setAllValues('params.Title', titles);
}
}
function fetchRundown()
{
ogscript.asyncPost('https://rundowncreator.com/luc/API.php?APIKey=Even&APIToken=o0YLzKCLkKmb2egv1Ti5HYv9oQbISI&Action=getRundowns', null, handleResults);
}
</api>
<ogscript handles="onload">
/*! block id=1000 !*/
fetchRundown()
/*!!
<block id="1000" type="function_fetchRundown" x="10" y="100" w="243" />
!!*/
/*!!<checksum>97f7d234533212934b6c5e069b1d31b0</checksum>!!*/</ogscript>
</meta>
<button buttontype="push" height="81" left="15" name="Refresh" top="17" width="172">
<task tasktype="ogscript">
/*! block id=1001 !*/
fetchRundown()
/*!!
<block id="1001" type="function_fetchRundown" x="10" y="100" w="243" />
!!*/
/*!!<checksum>2cd1be6cfe34db06a453cd5214acd084</checksum>!!*/</task>
</button>
<param expand="true" height="209" left="17" oid="params.table" showlabel="false" top="117" width="488"/>
</abs>#DashBoard