Hey,
I'm doing some development using JS unde Adobe AIR. What I want to do is create a request to a remote website (for authentication for example).
The problem is not AIR related, it's a JS thing I can't get right. What I want to do is to retrieve the request body but if I just return the "str" var it shows "undefined". I've tried to declare it 'globally' inside the function but it didn't work. I'm guessing there is some scope issue that I'm overlooking.
function doRequest(url){
var req = new XMLHttpRequest();
req.onreadystatechange = function(){
if (req.readyState == 4) {
var str = req.responseText;
runtime.trace("deRequest result: " + str);
return str;
}
};
req.open('GET', url, true);
req.send(null);
}