开发者

HTML5 - synchronize local DB with Server

I have an application which runs in ofline mode also using browsers local database. Now I want my application to sync this with my server. I want to perform the below tasks

  1. Check for a connection at regular intervals
  2. When I开发者_开发百科 have a connection send data to the server
  3. Get the updated data present on the server.

What should I do to accomplish my above goals?

Is WebSockets a solution to it?


You do not need WebSockets for this. I would suggest simply using XMLHttpRequest. You do need to keep track of what local data is un-synced to the server (either by placing references to un-synced data in a special "queue" when offline or by having a separate field in the local DB saying "synced"). When connected, read unsynced data and submit by XMLHttpRequest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜