zoukankan      html  css  js  c++  java
  • ajax轮循

    使用 AJAX 进行异步加载轮询操作。简单代码如下:

    <script>

    // 执行ajax轮循操作
    function polling(){
    var xmlhttp;
    // 判断浏览器--创建对象
    if ( window.XMLHttpRequest ){
    xmlhttp = new XMLHttpRequest();
    }else{
    xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    }
    // 与服务器建立连接
    xmlhttp.open( "GET", "polling.php", true );
    // 发送请求
    xmlhttp.send();
    // 监听事件 回调匿名函数 判断返回值
    xmlhttp.onreadystatechange = function(){
    if ( xmlhttp.status == 200 && xmlhttp.readyState ==4 ){
    alert( xmlhttp.responseText );
    }
    }
    }
    setInterval( "polling()", 1000 );

    </script>


  • 相关阅读:
    iptraf查看TCP/UDP某个特定端口的带宽与流量
    linux read 命令
    2 css常识二
    1 css常识
    18 表单
    17 事件
    16 DOM
    15 BOM
    14 函数-高级
    13 对象
  • 原文地址:https://www.cnblogs.com/laowenBlog/p/5944823.html
Copyright © 2011-2022 走看看