dsgffz2579 2013-04-11 00:14
浏览 81
已采纳

如何将数据从Android发送到PHP并显示它而不刷新页面

I successfully send data from Android to PHP and store in MYSQL database.

What I want is to display the data in my PHP page automatically without refreshing the page when data has been sent from and Android device. Is this possible, possibly using jQuery with AJAX?

Please explain how it can be done or point me to a resource where I can find such information.

  • 写回答

1条回答 默认 最新

  • dre26973 2013-04-11 00:19
    关注

    So you essentially want to update the page when data changes on the server.

    Two main options come to mind:

    1. Ajax poll

    Use setTimeout in conjunction with an ajax call to periodically call the server and see if anything changed. You already mention jQuery, that's certainly a good place to start. Get familiar with http://api.jquery.com/jQuery.ajax/. This is probably going to be your best bet.

    2. PubSub

    I use http://www.pubnub.com/ on one of my sites for this very purpose. The browser subscribes to a pubnub channel, and the server publishes on that channel anytime something changes on the server. This is obviously more work to get setup up front, and more applicable for rich client-side applications (mine is a single-page app).

    There are plenty of other implementations of PubSub as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条