简体   繁体   English

在线离线和PHP中的离线同步

[英]online offline and offline synchronization in php

I want to create a button in my page in php which can sync and update the databases from localhost to server and server to localhost. 我想在php页面中创建一个按钮,该按钮可以将数据库从localhost同步和更新到服务器,并将服务器更新到localhost。 Localhosts are having their own user ID and Password. 本地主机拥有自己的用户ID和密码。 I mean, If the internet is not working they can update their database offline and when there is internet they can update their database in server and at the same time the updated database from server should be updated in localhost also. 我的意思是,如果Internet不能正常工作,他们可以脱机更新数据库,而当Internet出现时,他们可以在服务器中更新数据库,同时从服务器更新的数据库也应该在localhost中更新。

You should try using localStorage when the browser goes offline: 浏览器离线时,您应该尝试使用localStorage

  1. http://diveintohtml5.info/storage.html http://diveintohtml5.info/storage.html
  2. http://www.w3schools.com/html/html5_webstorage.asp http://www.w3schools.com/html/html5_webstorage.asp

Then later on you should use AJAX after your browser establishes the Internet connection again, so you can send the localStorage contents to your server: 然后,稍后您应该在浏览器再次建立Internet连接之后使用AJAX,因此可以将localStorage内容发送到服务器:

  1. http://api.jquery.com/jQuery.ajax/ http://api.jquery.com/jQuery.ajax/
  2. Sending localStorage variables through the jQuery Ajax function without it being in the url 通过jQuery Ajax函数发送localStorage变量,而不将其放在url中
  3. http://www.w3schools.com/ajax/default.ASP http://www.w3schools.com/ajax/default.ASP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM