javascript - PhoneGap + AngularJS failed to read file that is just created -


i'm using angularjs in phonegap 3.5.0 project , use on ios 5 , 6 xcode.

i try read file write previously. i've empty string instead of value of response json.

$http.get(api + '/content') .success(function (response) {     // response json     console.log(response);      window.requestfilesystem(localfilesystem.persistent, 0, function (filesystem) {         filesystem.root.getdirectory('json', {create: true}, function (direntry) {             direntry.getfile('contents.json', {create: true, exclusive: false}, function (fileentry) {                 fileentry.createwriter(function (filewriter) {                     filewriter.onwriteend = function (e) {                         // not working...                         fileentry.file(function (file) {                             var reader = new filereader();                              reader.onloadend = function (e) {                                 // e.target.result empty string (!?)                                 console.log(e.target.result, typeof e.target.result);                             };                              reader.readastext(file);                         });                     };                      filewriter.write(response);                 });             });         });     });  }); 

i have working version works photos:

window.requestfilesystem(localfilesystem.persistent, 0, function(filesystem){                 filesystem.root.getdirectory("photos", {create: true, exclusive: false}, function(dir) {                     dir.getfile("photo_"+date.now()+".jpg", {create: true, exclusive: false}, function(fileentry){                         fileentry.createwriter(function(writer){                             writer.onwriteend = function (evt) {                                 scope.processphoto(fileentry.tourl(), $(element).index());                             };                             writer.write(element.find('input')[0].files[0]);                         }, fail);                     }, fail);                 }, fail);             }, fail); 

the function handles fail is

function fail(error) {             console.log(error.code);         } 

i cannot see difference in why mine works , not, try using fail function drill down possible error code , cause particular case.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -