0

What I would like to do is push JSON data from a PHP script to Vue (in the view of an MVC PHP framework), comparable to what you would see in an online exchange where the data updates in near real time. So without a page reload.

Now I understand you can use fetch to fetch data (and probably set an interval so it does that every x seconds), but I would like the UI to update in (near) real-time as the PHP script outputs the data. How to do this? Preferably without using a third party like pusher.com.

Some details about the UI:

  • It's about 10 to 30 rows in a <table>

  • In each row there is one status label and a few numbers that would get updated

  • There are a few other generic elements on the page that need an update (eg overall status label)

eskimo
  • 2,421
  • 5
  • 45
  • 81
  • Possibly useful: https://router.vuejs.org/en/advanced/data-fetching.html and https://stackoverflow.com/questions/31715179/differences-between-websockets-and-long-polling-for-turn-based-game-server – webketje Jan 16 '18 at 21:51
  • I've seen the docs on data-fetching, but from that page: "Sometimes you need to fetch data from the server". I would like to do it the other way around (push JSON from server to Vue instead of making Vue fetch from the server). I'll have a browse on websockets + php + Vue. – eskimo Jan 16 '18 at 22:32

0 Answers0