Advertisement
Guest User

Untitled

a guest
Jul 25th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function call_to_read_a_file(){
  2. readFile(fs,'/path/to/file.txt',function(res){
  3.     alert(res);
  4. });
  5. }
  6. function readFile(fs, file_path, success_fn){
  7.     fs.root.getFile(file_path, {}, function(fileEntry) {
  8.         fileEntry.file(function(file) {
  9.             var reader = new FileReader();
  10.             reader.onloadend = function(e) {
  11.                 success_fn(this.result);
  12.             }
  13.             reader.readAsText(file);
  14.         }, errorHandler);
  15.     }, errorHandler);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement