• 我的Ajax学习笔记


    1.不同的浏览器创建 XMLHttpRequest 对象的方法(通用函数)
    <script type="text/javascript">
    function ajaxFunction()
    {
    var xmlHttp;
    try
        {
       // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
    catch (e)
        {
      // Internet Explorer
       try
          {
        //IE 6.0+
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
       catch (e)
          {
          try
             {
            //IE 5.5+
             xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
             }
          catch (e)
             {
             alert("您的浏览器不支持AJAX!");
             return false;
             }
          }
        }
    }
    </script>
    2.一个简单的Ajax程序范例
    <html>
    <body>
    <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()
          {
        //4代表请求已完成
          if(xmlHttp.readyState==4)
            {
             document.myForm.time.value=xmlHttp.responseText;
            }
          }
        xmlHttp.open("GET","time.asp",true);
        xmlHttp.send(null);
    }
    </script>
    <form name="myForm">
    用户: <input type="text" name="username" onkeyup="ajaxFunction();" />
    时间: <input type="text" name="time" />
    </form>
    </body>
    </html>

    这是 "time.asp" 的代码:
    <%
    response.expires=-1        //页面不缓存
    response.write(time)
    %>
  • 相关阅读:
    设置和查看时间
    通过linux ssh远程登录另一台Linux,无需密码,用证书验证
    openssl生成自签名证书
    技术集锦
    centos系统安装中文字体几种方法
    集群中几种session同步解决方案的比较
    leetcode 88. C++ 合并两个有序数组
    CycleGAN --- Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
    剑指offer---二叉树的深度
    C++基础(2)
  • 原文地址:https://www.cnblogs.com/guoxiaowen/p/1125344.html
Copyright © 2020-2023  润新知