Unanswered: How to upload data from local storage?
Unanswered: How to upload data from local storage?
Hello
I'm working on an app to conduct a survey. I've written a couple of PHP web services to return sufficient data fromm a MySQL database to authenticate the user and then ask her a series of questions. Although, I haven't got that far yet, I think I can see how to save the user's answers to local storage. The bit I don't get, though, is how, when the survey is complete, I upload the stored data and squirt them into the database.
If someone could point me to the right place in the docs, that would be really helpful.
Thanks.
There is a localStorage proxy you can use. If you read through it, it should help you out. You have to make sure that the browser supports local storage, though. Also, this proxy guide should help
Thank you. From those two links I can see how I would save data to local storage and how I can send data back to the database using a POST to the web service which I used to GET the records in the first place (using X.save()). I can't really do the latter, though, because I GET a bunch of questions with my proxy and need to PUT/POST a bunch of answers (whose records have a different structure from the questions). What I would like to do is save the answers locally and then POST them when the user has finished the survey. So I need some way to squirt the answers records from local storage up to a web service. I'm afraid I don't see how that's done, unless I somehow copy the data from a local store with its local storage proxy and stick them into a store with a rest proxy and then somehow connect from the latter store with a POST request (maybe that requires a writer?). Sorry to be thick, but I'm pretty new to Sencha and am struggling with the docs.
Are you planning on saving drafts of the surveys then? If you are just filling it out and sending it then you shouldn't need local storage at all. I'm not sure exactly what you are trying to do here.
Hello again, Jerome. Thanks for following this up. My plan is to save locally the user's answers to the survey questions so that they can then upload them when convenient. It seemed to me that it would be convenient for the user to work through the questions which have been downloaded to a local store, save their answers to a local store and then upload them to the server when they feel like it. It did occur to me that they could save each answer to a store which would immediately POST (save) each answer record, but I thought that that would be an unpleasant experience for them because of network latency, dropped connexions etc.
So currently the app GETs a user record against which they authenticate themselves and it then GETs all of the questions of the appropriate survey. The idea is that they can then answer the questions even if they're not connected to the network and upload their answers when they do have a connexion.
It looks to me like I probably need Ext.data.writer.Json to pull the answers from whatever store I use for answer records and squirt them up to the server. The documentation's a bit sparse, though.
I understand what you are trying to do now. I think you should look into the Memory and SessionStorage proxies too. Then you can send the answers via Ajax.