Hi, I’m using javascript to manage what appears on my UI5 tabs, and I can’t seem to get a value outside of the tab functions, at the start of the file. I have a URL that works perfectly well in my browser:
But when I try to use javascript, I get nothing back:
var tester=fetch_single_var ( url );
function fetch_single_var ( url ) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", url, true );
xmlHttp.send();
return xmlHttp.responseText;
}
alert(‘test’+tester);
I’m wondering if anyone else has run into this problem? I’m placing this code at the start of the javascript file that is called when the wrench icon is clicked, bringing up the tabbed display. I’m doing this so that I can control what is displayed on the tabs, before they are selected by the user.
When I am inside a tab function, I can use the usual LUUP call method:
get_device_state(device,RT_Device_SID,“User”,0);
but that won’t work at the beginning of the javascript file, only from within a tab function (as declared in the json config file). All I want to do is get one variable before the user clicks a tab, but it seems very difficult to do.
One other thing I noticed is that I’m using one js file with multiple functions for 3 tabs, and it is getting loaded 3 times - should I have 1 js file per tab?
Tks, AB