Categories: javascript, php, ajax

I want to display an icon or message on a different webpage whenever an ajax page is actively refreshing original webpage. Can this be done?

1 answer

I have a webpage (index.php)that is using ajax to refresh a php page (dbcheck.php) which is pulling data from a mysql DB and displaying it. The ajax is refreshing the script(dbcheck.php) every second so its almost in real time. I want to display an icon or message on a third webpage, on the same server, whenever the ajax page is actively refreshing so I know the page is active.(someone is on the page) Can I add a second ajax POST to index.php that POSTS to the 3rd page or ? Does anyone have any ideas how this could be achieved?

index.php:  <script type="text/javascript">// <![CDATA[ $(document).ready(function() {   $.ajaxSetup({ cache: false  });   var rowdisplayvalue = "<?php echo $rowdisplayvalue; ?>";//row display variable passed through    setInterval(function() {  $('#divToRefresh').load('dbcheck.php', {rowdisplayvalue: rowdisplayvalue}); }, 1000); // refers to the time to refresh the milliseconds. });  // ]]> </script> 

All answers to this question, which has the identifier 61198518

The best answer:

You can't post to a page, you can only post from a page. Use comet (long polling Ajax) or web sockets to read the event in the other session. You need some mechanism of recording the event triggered by monitored session for this to be readable by the monitoring session.

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type is referenced as an interface from”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data