For example, one page adds an entry using ajax . But on other pages, everything is as before, until the page is reloaded. How to update the block with records on other pages at the moment when the record was added?

  • one
    Is the entry added, as I understand it, into the database? Are other pages loaded in the same way with ajax-tools? How is the content loaded into the "block with records"? It would be nice to somehow reveal the topic ... - Deonis
  • one
    Records in the database. This is the same page, just open on different computers, by different users. When the page is reloaded, entries are added via php, and then ajax. - Svyatoslav

2 answers 2

I think it is worth sending a request every second checking whether a new entry has been added. Well, when loading the page, get the last record from the database of the last record and place it in the javascript variable and then every second by means of Ajax to check if there are records in the database that have ID more than in our variable. If there are, then return them when help jaykvarri add.

  • It will not slow down the page? - Svyatoslav
  • No, it should not. I did this chat and it worked just to cheer! and yes when we added entries it is worth updating our variable))) - green93
  • Thanks, I will try)) - Svyatoslav
  • 2
    and the server at you will not lay down with requests every second? How many users will be sitting on this application? And the second - and if the record is deleted? but at this time have not yet added new entries - then your php script will not take data from the table, and therefore the data will be irrelevant? The same thing with the change of record - the person first entered and then corrected - again until the data is added, the page will contain irrelevant data ( - Ale_x
  • Nobody said anything about deleting or changing a record! Driving from scratch (come up with a reason and drove). And on account of whether the server will fall, I do not think. And in general, except to criticize you, nothing helped. - green93

Here's a similar question - Show new comments without reloading . There is my answer.

I think this solution is suitable for you.