Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@benbahrenburg
Created July 25, 2011 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benbahrenburg/1103324 to your computer and use it in GitHub Desktop.
Save benbahrenburg/1103324 to your computer and use it in GitHub Desktop.
Saving XHR Results to a file
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
var results = this.responseText;
Ti.API.info('Results from xhr Lookup = ' + results );
var supportDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'my_support');
if(!supportDir.exists()){
supportDir.createDirectory();
}
var supportFile = Ti.Filesystem.getFile(supportDir.nativePath,'mydebug.txt');
if(supportFile.exists()){
supportFile.deleteFile();
}
//If this is a json object you need to stringify
supportFile.write(results);
};
// open the client
xhr.open('GET','http://twitter.com/statuses/show/123.xml');
// send the data
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment