I'm wondering, because if I write a downloaded JSON file to the filesystem and try to decode it right after writing, the JSON parser throws an exception. If I try do decode it again (without newly writing to the filesystem) it works on the exact same file.
Does the function file.write() return immediately, thus before the filewriting-process has finished?
2 Answers
If your code is as such:
xhrFunctionToGetFile(); ioFunctionToReadFile();Then you will experience this problem. If however, you call your write function from inside the
onload method of the httpClient, your io operations will not start until after a successful download.
You may check if file is really written successfully first... if(f.write("sth")===false){
}
Your Answer
Think you can help? Login to answer this question!