req=ReadFile(“myfile.txt”) used to work (Offlineapp.manifest) before going to PWAs with the ServiceWorker. With extraFiles containing the name of the text file upon a full deploy to the server this file can be seen in the Application/Cache Storage when running Chrome on a PC. It’s there along with all of the other picture files used by the app and those work properly when offline. Is there some other method to use for reading these cached files?
I also tried req=Ajax("myfile.txt’), no luck.
Its my understanding ReadFile is for reading a file on the server where the webapp is deployed.
Your ajax call for reading a file will need to call a php file to read a file on your server.
In my code I have
The php file on the server looks like this
$a = file_get_contents($_GET['urlToGet']);
I’m trying to read a file when the Internet is offline, so reading a php script on the server cannot be accessed.
As stated, reading a file with ReadFile while offline worked in previous Offlineapp.manifest apps, now with PWA it does not work. Providing the full link to the server was also tried, but failed.
Are there any error messages on the Console?
Error in Consol: jquery2.js:4 GET https://prograsa.com/hw/version.txt net::ERR_INTERNET_DISCONNECTED
where hw is the name of the app deployed to the server.
Testing with AS sample HelloWorld with Button1 modified and property Make PWA? = True:
'MsgBox "Thanks for clicking!"
C = "version.txt"
If req.status = 200 Or req.status = 0 Then
C = req.responseText
alert("got version.txt: " & req.status & ":" & C)
alert("unable to get file")
where version.txt is in extraFiles.
Deploy to server, run the app and the correct number in version.txt is returned with Button1_onclick.
From Chrome go to consol (F12) and select Application/Cache Storage and all of the cached files are there, including version.txt.
Select Network/offline. Press Button1_onclick and req.status is 0, not 200, and req.responsText is undefined.
I’m having the same problem with v188.8.131.52
Were you able to resolve this?
I’m using this code now and it is working:
randomValue = SysInfo(10)
C = URLServer & "recipeshopHelp/RecipesHelp.txt?" & randomValue
If req.status=200 Or req.status = 0 Then
ServerRecords = req.responseText
M = C & " not found."
Call ShowMsg(M,0,"Updating Settings") 'ShowMsg() is my internal function not part of App Studio basic
The randomValue is used to fool the browser into not using a cached file.
However it seems to me that these 2 bits of code have different purposes.
The first is looking for version.txt file when the app is disconnected from the net. A PWA should find this file but it is not finding it.
The second is not off line but making sure the file is down loaded rather than the local file being used.
My problem is that in the first case where the file is not found when off line but it should be for a PWA.