Rajasekaran Raji
Rajasekaran Raji

Reputation: 74

How to save a form data and sync to server in Phonegap?

I am developing a android app in phonegap. It is a feedback app, customer fill the details and submit to us. I am using ajax post to connect to server file(post.php) and sent sms and emails to customer. Sometimes internet connection is so poor the customer data is not post to server. How to save a form data in phonegap and sync data?

Upvotes: 0

Views: 305

Answers (1)

Víctor
Víctor

Reputation: 3039

My way to do that:

When you are doing AJAX to your server, add an error method, if the connexion fails.

If this happens. Save your data in localStorage.

When the app is resumed, or when user clicks "resubmit", or whenever you want, create a function "syncronize".

In this function, get the data from localStorage, and do again the AJAX, and in the AJAX success, delete it from localStorage

Upvotes: 1

Related Questions