Note that there are some explanatory texts on larger screens.

plurals
  1. POIn one project I can write a file but in the other I can't, really strange
    primarykey
    data
    text
    <p>In one project I managed to get the file writing with phonegap working like so:</p> <pre><code>$("#download").live("click", function(){ writeFile(); }); function writeFile(){ $.get("http://www.bartdekimpe.be/anoire/index.php/admin/getGamesUserJson/34", function(result){ json = result; removeHTMLTags(); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); }); } function removeHTMLTags(){ if(json){ var strInputCode = json; /* This line is optional, it replaces escaped brackets with real ones, i.e. &lt; is replaced with &lt; and &gt; is replaced with &gt; */ strInputCode = strInputCode.replace(/(&amp;nbsp;)*/g,""); strInputCode = strInputCode.replace(/&amp;(lt|gt);/g, function (strMatch, p1){ return (p1 == "lt")? "&lt;" : "&gt;"; }); // strTagStrippedText = '"'; strTagStrippedText = strInputCode.replace(/&lt;\/?[^&gt;]+(&gt;|$)/g, ""); strTagStrippedText = $.trim(strTagStrippedText); // overbodige spaties weghalen //strTagStrippedText += '"'; }}; function gotFS(fileSystem) { fileSystem.root.getFile("readme.txt", {create: true}, gotFileEntry, fail); } function gotFileEntry(fileEntry) { fileEntry.createWriter(gotFileWriter, fail); } function gotFileWriter(writer) { writer.onwrite = function(evt) { console.log("write success"); }; writer.write(strTagStrippedText); readFile(); // contents of file now 'some sample text' // writer.truncate(11); // contents of file now 'some sample' // writer.seek(4); // contents of file still 'some sample' but file pointer is after the 'e' in 'some' //writer.write(" different text"); // contents of file now 'some different text' } // Einde FILE WRITER function fail(error) { console.log(error.code); } </code></pre> <p>In the other project I do exactly the same thing, and it won't work, I created another project cause I needed to begin all over again. I do it like so:</p> <pre><code>$(".startNew").live("click", function(){ writeFile(); $.mobile.changePage($("#games")); krijgSpellen(); }); function writeFile(){ navigator.notification.alert("write file"); $.get("http://www.bartdekimpe.be/anoire/index.php/admin/getGamesUserJson/34", function(result){ json = result; removeHTMLTags(); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); }); } function removeHTMLTags(){ if(json){ var strInputCode = json; /* This line is optional, it replaces escaped brackets with real ones, i.e. &lt; is replaced with &lt; and &gt; is replaced with &gt; */ strInputCode = strInputCode.replace(/(&amp;nbsp;)*/g,""); strInputCode = strInputCode.replace(/&amp;(lt|gt);/g, function (strMatch, p1){ return (p1 == "lt")? "&lt;" : "&gt;"; }); // strTagStrippedText = '"'; strTagStrippedText = strInputCode.replace(/&lt;\/?[^&gt;]+(&gt;|$)/g, ""); strTagStrippedText = $.trim(strTagStrippedText); // overbodige spaties weghalen //strTagStrippedText += '"'; }}; function gotFS(fileSystem) { fileSystem.root.getFile("readme.txt", {create: true}, gotFileEntry, fail); } function gotFileEntry(fileEntry) { fileEntry.createWriter(gotFileWriter, fail); } function gotFileWriter(writer) { writer.onwrite = function(evt) { console.log("write success"); }; writer.write(strTagStrippedText); readFile(); // contents of file now 'some sample text' // writer.truncate(11); // contents of file now 'some sample' // writer.seek(4); // contents of file still 'some sample' but file pointer is after the 'e' in 'some' //writer.write(" different text"); // contents of file now 'some different text' } // Einde FILE WRITER function fail(error) { console.log(error.code); } </code></pre> <p>It won't write the file, really strange, when I do this: </p> <pre><code>$(".startNew").live("click", function(){ writeFile(); $.mobile.changePage($("#games")); krijgSpellen(); }); </code></pre> <p>it doesn't write a file but when I do this: </p> <pre><code>$(".startNew").live("click", function(){ writeFile(); }); </code></pre> <p>It does work and it writes a file</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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