0

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 Answer 1

1

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.

1
  • No it's not (you can of course check out their website!) which is also why it's not likely your best place to start. Try the ajax poll approach, I think it'll do what you need. It's worth understanding, if nothing else. I just wanted to point out other options.
    – jszobody
    Apr 11, 2013 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.