Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ended up using simon mcondalds solution and didnt use jQuery.deferred</p> <p>Basically put all the items i had to get from the web in an array when one was succefully retrived, just remove that item from the array and then call the same function again. Eventually the array.length will have </p> <p><a href="https://gist.github.com/macdonst/3835045" rel="nofollow">https://gist.github.com/macdonst/3835045</a></p> <p><strong>Example code here:</strong></p> <pre><code>var remoteFiles = []; function downloadRemotePDF() { var local2User = JSON.parse( localStorage["locallessons"] ); $.each(local2User, function(key) { remoteFiles.push(optionsJSON + local2User[key].idcountries + '/' + local2User[key].idcurriculum + '/' + local2User[key].idoptions + '/pdf/' + local2User[key].pdfname); } downloadFile(); } function downloadFile() { // No files left, stop downloading if (remoteFiles.length == 0) { return; } var remoteFile = remoteFiles.pop(); var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/')+1); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) { fileSystem.root.getFile(localFileName, {create: true, exclusive: false}, function(fileEntry) { var localPath = fileEntry.fullPath; if (device.platform === "Android" &amp;&amp; localPath.indexOf("file://") === 0) { localPath = localPath.substring(7); } var ft = new FileTransfer(); ft.download(remoteFile, localPath, function(entry) { // Do what you want with successful file downloaded and then // call the method again to get the next file downloadFile(); }, fail); }, fail); }, fail); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload