Reputation: 1708
I am beginner in jQuery Mobile. I have a simple form which has 10 fields.
My requirement is, when user submit this form check for internet connection if it's available then store the data in DB else store data locally. Whenever internet connection is available sync those data and upload to server.
how can i achieve this? Please guide me.
Thanks
Upvotes: 0
Views: 638
Reputation: 5236
One way to implement this is to use a standard jQuery ajax call to the database.
If it returns an error (which would, among other things, indicate that an internet connection may not be available) copy or move the data (depending on what you need) to an array specifically used as a pending upload queue.
Then have a function running via setInterval to check if there is data in the pending upload queue, if there is try to upload it, if it succeeds remove the uploaded data from the queue. If it fails leave the data for the next try.
Upvotes: 2