-1

I'm making in plan (organizer) app in jQuerymobile with the help of php. The app is pretty basic. But my question is: is it possible to change the color of square to green on my mobile that it will change on my desktop aswell (10second delay max). Someone told me that firebase was a possibilty or ajax. But when i try to google on the solutions i can't find a thing about it. So what do you guys suggest in a way how to fix this?

Have a nice day, Simon

  • You question is confusing. Do you want to know about Ajax or changing the color of your box. You could elaborate it a bit more. – Sandeep Dec 08 '16 at 09:34
  • 1
    I would suggest a websocket. – Daan Dec 08 '16 at 09:40
  • aah my bad, i want to know the solution for the problem i'm describing below. When i change a square on my mobile phone, i want to see it changed on my desktop aswell. But with what program is this possible and how? – simon schaminee Dec 08 '16 at 09:41
  • You'll need a websocket (if supported) or long polling otherwise. There are some libs that abstract that for you, like http://socket.io/ – Tiago Engel Dec 08 '16 at 10:22

2 Answers2

1

Cosidering you're writing your app in javascript, you can use pouchdb. Pouchdb is javascript database that syncs information with the couchdb database, and couchdb can replicate its information transparently with no aditional effort.

Another approach is using websocket or long polling when websockets are not supported, but this approach involves a little more "work" than the pouchdb approach.

I have a TodoMVC toy project on my github using websockets to do real time updates, this isn't the same environment you're using but it can give you some insights on how websockets work. You can check it out here

Tiago Engel
  • 3,533
  • 1
  • 17
  • 22
0

As Daan pointed you what you're really looking for to achieve something that you described are websockets. Though you could use a polling approach with jquery to do the same, it really isn't as elegant as using websockets. There are a lot of websocket libraries available for which a detailed answer is given in this stackoverflow thread

Firebase is a backend and simplifies a lot of the development for you especially to build real time applications like the one you wanted to. Have a look at Firepad. Open it up on two different browsers and you'll be able to see it's real time nature. As you edit on one browser screen, the content will appear on the other.

You can use this as a starting point, look into it's code on github and build your app. I think you could consider building apps with meteor

Community
  • 1
  • 1
Sudheesh Singanamalla
  • 2,283
  • 3
  • 19
  • 36