123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wb="http://open.weibo.com/wb" style="overflow: hidden;">
- <head>
- <script>
- function poll() {
- var start = 0;
- var time = null;
- var xhr = new XMLHttpRequest();
- var data = "";
- xhr.open("POST", "http://127.0.0.1:1473", true);
- xhr.onreadystatechange = function () {
- if (xhr.readyState == 3 && xhr.status == 200) {
- clearTimeout(time);
- var len = xhr.responseText.length;
- data += xhr.responseText.substring(start, len);
- start = len;
- console.log(data)
- time = setTimeout(function () {
- clearTimeout(time);
- data = "";
- }, 100);
- }
- }
- xhr.onerror = function (err) {
- console.log(err);
- }
- xhr.send();
- }
- window.onload = function () {
- poll()
- }
- </script>
- </head>
- <body>
- </body>
- </html>
|