zoukankan      html  css  js  c++  java
  • Ajax实例化(五)

    客户端:

    <head>

        <title></title>

        <script type="text/javascript">

            function ajaxFunction() {

                var xmlHttp;

                try {

                    // Firefox, Opera 8.0+, Safari

                    xmlHttp = new XMLHttpRequest();

                }

                catch (e) {

                    // Internet Explorer

                    try {

                        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

                    }

                    catch (e) {

                        try {

                            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

                        }

                        catch (e) {

                            alert("您的浏览器不支持AJAX");

                            return false;

                        }

                    }

                }

                xmlHttp.onreadystatechange = function () {

                    if (xmlHttp.readyState == 4) {

                        document.myForm.time.value = xmlHttp.responseText;

                    }

                }

                var dt = new Date();

                xmlHttp.open("GET", "AjaxTime.ashx?dt=" + dt.getSeconds(), true); //

                xmlHttp.send(null);

            }

    </script>

    </head>

    <body>

    <form name="myForm">

    用户: <input type="text" name="username" onkeyup="ajaxFunction();" />

    时间: <input type="text" name="time" />

    </form>

    </body>

    </html>

    服务端:

    public void ProcessRequest(HttpContext context)

            {

                context.Response.ContentType = "text/plain";

                DateTime dt = DateTime.Now;           

                context.Response.Write(dt);

            }

  • 相关阅读:
    SpringBoot中mybatis配置自动转换驼峰标识没有生效
    mybatis-plus-扩展使用
    myabtis-plus使用
    mybatis-plus特性
    Mariadb Galera Cluster 故障快速拉起
    galera集群启动异常问题汇总
    Galera Cluster grastate.dat文件详解
    mongodb配置文件详解
    wsrep配置一览
    MySQL Galera cluster集群常用参数说明
  • 原文地址:https://www.cnblogs.com/wenwei/p/2208414.html
Copyright © 2011-2022 走看看