0

I have developed app using phonegap, but have one issue on setting value to fileName variable inside reader.onloadend = function(e){}. Seems like locally it works, because alert message show proper value of fileName, but when i am trying to use outside onloadend, it doesnt work, mean it returns that fileName value is undefined.Where is the problem and how it can be solved? Trying to get value after calling "parent" function of .onloadend. here is code of function:

 function gotFile(fileEntry) {
     fileEntry.file(function(file) {
         var reader = new FileReader();
         reader.onloadend = function(e) {
             fileName = slice_file(reader.result);
             alert(fileName);
         }
         reader.readAsText(file);
     });
     del();
 }
  • sorry, now it seems to look better. – Edward Ryzhewski Feb 19 '16 at 23:36
  • Possible duplicate of [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Mike Cluck Feb 19 '16 at 23:37
  • @EdwardRyzhewski Cordova-3 will be removed in May of 2016 because of security issues. -- Please **answer the following questions in your post**. Since this appears to be your first post on this subject. Is this your first hybrid App? Are you using the Desktop App? Are you using [CLI, SDK or Build](https://github.com/jessemonroy650/top-phonegap-mistakes/blob/master/new-to-Phonegap.md#001) ? Please do not assume the answer, please read the link. Once you have answer the question *in the post*, respond in the comments so I know you have added information to the post. –  Feb 20 '16 at 05:05

0 Answers0