Created
July 25, 2011 00:54
-
-
Save benbahrenburg/1103324 to your computer and use it in GitHub Desktop.
Saving XHR Results to a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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