zoukankan      html  css  js  c++  java
  • Ajax

    <!doctype html>
    <html lang="en">
     <head>
      <meta charset="UTF-8">
      <title>Ajax</title>
      <script>
        $(function(){
            $('btn').onclick = function(){
                //创建ajax对象
                //ie6以下:new ActiveXObject('Microsoft.XMLHTTP');
                var xhr = null;
                try{
                    xhr = new XMLHttpRequest();
                }catch (e){
                    xhr = new ActiveXObject('Microsoft.XMLHTTP');
                }
                //发送方式
                xhr.open('post','1.txt',true);
                //接受
                xhr.send();
                //触发
                xhr.onreadystatechange = function(){
                    console.log( this );
                    //判断状态
                    if (xhr.readyState == 4)
                    {
                        alert( xhr.responseURL );
                    }
                }
            }
        })
        function $(v){
            if (typeof v === 'function')
            {
                window.onload = v;
            }else if (typeof v === 'string')
            {
                return document.getElementById(v);
            }else if (typeof v === 'object')
            {
                return v
            }
        }
      </script>
     </head>
     <body>
        <input type='button' value='按钮' id='btn'/>
     </body>
    </html>
  • 相关阅读:
    下载Spring
    Jsp的静态引入和动态引入
    Jsp代码书写
    Jsp的page指令
    Jsp注释
    Python学习笔记Day04
    sublime
    sublime
    爬虫学习02_数据提取
    爬虫学习01_爬虫基础与requests模块
  • 原文地址:https://www.cnblogs.com/jokes/p/9813076.html
Copyright © 2011-2022 走看看