Created
August 16, 2011 02:53
-
-
Save khajer/1148352 to your computer and use it in GitHub Desktop.
read file from xhr and write on system
This file contains hidden or 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.open("GET","http://www.yourdomain.com/test.txt"); | |
| xhr.onload = function(){ | |
| statusCode = xhr.status; | |
| if(statusCode == 200) | |
| { | |
| var doc = this.responseText; | |
| var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'test.txt'); | |
| f.write(doc); | |
| } | |
| }; | |
| xhr.send(); | |
| var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'test.txt'); | |
| var contents = f.read(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment