zoukankan      html  css  js  c++  java
  • AJAX 代码框架

    Javascript

    <!DOCTYPE html>
    <html>

    <head>
    <meta charset="UTF-8">
        <title>Ajax Test</title>


    <script type="text/javascript">
        
        function getDate()
        {
            var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            
            if(!xmlhttp)
            {
                alert("Create xml error");
            }
            
    // GET 方式如果是固定请求,会从缓存中读取信息,解决缓存问题,可在 URL 后加 "&ts="+new Date(), 每次都会变化的东西
            xmlhttp.open("GET", "https://www.AppAnnie.com", false); // 如果请求的 URL 中含有中文,需要使用 javascript 的一个函数 encodeURI("中文")
          
         xmlhttp.onreadystatechange = function()
            {
            
                if(xmlhttp.readystate==4)
                {
                    
                    if(xmlhttp.status==200)
                        {
                            alert(xmlhttp.responseText);
                            document.getElementById("showdate").value = xmlhttp.responseText;

                        }
                    else
                        {
                            alert("Ajax server error");
                        }
                }

            }

            xmlhttp.send();

        }
    </script>

    </head>

    <body>

    <input id="showdate">
    <button type="button" onclick="getDate()">Get Date</button>
    </body>
    </html>
  • 相关阅读:
    Debian Linux 5 时间设定相关与时间同步
    javascript的基本类型
    判断浏览器的类型
    用C#打开IE
    MAC ADDRESS LOOKUP
    HP大中华区总裁辞职信
    原始的JavaScript创建
    .NET应用程序域
    显示接口实现与隐式接口实现
    [转载]MVC Razor 语法(转)
  • 原文地址:https://www.cnblogs.com/TikyZheng/p/4644219.html
Copyright © 2011-2022 走看看