• 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);

            }

  • 相关阅读:
    ElasticSearch入门 第一篇:Windows下安装ElasticSearch
    Elasticsearch+Logstash+Kibana教程
    MySQL组合索引最左匹配原则
    mysql 有哪些索引
    MySQL配置优化
    MySQL分区和分表
    MySQL优化
    MySQL锁详解
    MySQL各存储引擎
    MySQL索引类型
  • 原文地址:https://www.cnblogs.com/wenwei/p/2208414.html
Copyright © 2020-2023  润新知