The reason why it didn't work is quite simple in fact: the request object isn't defined in the context of processReadyStateChange.
You could've fixed this by defining the processReadyStateChange function
inside your getData function, like this:
code:
function getData()
{
var TYPE = "GET"; //use GET to request information and POST to send information
var URI = "http://twitter.com/statuses/user_timeline/__XD__.json"; //whatever server and or form you want to communicate with
var ASYNC = true; //if false script will pause until the request is complete
request.open(TYPE, URI, ASYNC);
request.onreadystatechange = processReadyStateChange;
request.send(null);
function processReadyStateChange()
{
Messenger.MyPersonalMessage = "Twitter: Loading...";
if(request.readyState == 4 && request.status == 200)
{
json = eval( request.responseText )
Messenger.MyPersonalMessage = "Twitter: " + json[0].text
}
}
}
When you do this, the request variable will still be defined in the scope of processReadyStateChange when it's been called by the XMLHTTP request (which is also the case in your method). You can choose which method you want to use, the method above may be a bit nicer to read but there's nothing wrong with the way you did it.