Guest User

Untitled

a guest
Jan 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. var updates = new XMLHttpRequest();
  2. updates.onreadystatechange = function(){
  3. "use strict";
  4. if(updates.readyState === 4 && updates.status === 200){
  5. console.log(updates.responseXML);
  6. }
  7. };
  8.  
  9. var timer = 0;
  10. clearInterval(timer);
  11. timer = setInterval(function(){
  12. "use strict";
  13. updates.open('GET','scripts/check_for_notifications.php', true);
  14. updates.send();
  15. },2000);
  16.  
  17. $response = new SimpleXMLElement('<xml/>');
  18.  
  19. $update = $response->addChild('update');
  20. $update->addChild('content', 'New message');
  21. $update->addChild('redirect', 'some link');
  22. $update->addChild('date', '1.1.2019 12:00');
  23.  
  24. header('Content-type: text/xml');
  25. print($response->asXML());
  26.  
  27. updates.open('GET','scripts/check_for_notifications.php&nocache=' + new Date().getTime(), true);
Add Comment
Please, Sign In to add comment