Simulate graph states in the browser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
493B

  1. function poll() {
  2. var xmlhttp = new XMLHttpRequest();
  3. xmlhttp.onreadystatechange = function() {
  4. if (xmlhttp.readyState == XMLHttpRequest.DONE) {
  5. if (xmlhttp.status == 200) {
  6. update(xmlhttp.responseText);
  7. }
  8. }
  9. };
  10. // Send the request
  11. xmlhttp.open("GET", "/graph", true);
  12. xmlhttp.send();
  13. };
  14. function update(s) {
  15. json = JSON.parse(s);
  16. graph.update(json);
  17. }
  18. // Launch the polling loop
  19. setInterval(poll, 1000);