After getting some data (xmlHttp.responseText) from the web I now need the result to be put back into my event sheet.
My global variable is called 'returned_data' (its a string)
I tried runtime.globalVars.returned_data = xmlHttp.responseText but my global variable will not change despite the fact that the alert with the same data displays perfectly, as does the console log with the returned data. I need to get the returned data back to the event sheet for further manipulation.
Here is the JS script
function apiPostRequest(request, body) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", baseApiURL + request, false );
xmlHttp.setRequestHeader('Content-Type', 'application/octet-stream');
xmlHttp.setRequestHeader('X-Auth-token', token);
xmlHttp.send(body);
console.log("Resp: "+xmlHttp.responseText);//PRINTS RESULT PERFECTLY
alert ("Resp :"+xmlHttp.responseText);//PRINTS RESULT PERFECTLY
runtime.globalVars.returned_data = xmlHttp.responseText;//DOES NOTHING - Global ver is not changed
return xmlHttp.responseText;
}