• 最初的ajax案例


    ----------------------原始的ajax:
     function guo() {
                var xhr
                if (XMLHttpRequest) {
                    xhr = new XMLHttpRequest();
                }
                else {
                    xhr = ActiveXObject("XMLHttpRequest");
                }
                //ie5 和ie6是activeobject;
                //请求方式,地址,是否异步;
                xhr.open("get", "../Handler/test.ashx", true);
                //发送请求
                xhr.send();
                 //readystate:0未初始化;1,已打开,2,已发送,3正在接受,4,已加载
                xhr.onreadystatechange = function (data) {
                    if (xhr.readyState == 4) {
                        alert(xhr.responseText);
                    }
                };
            }
    --------post方式
     function guo() {
                var xhr
                if (XMLHttpRequest) {
                    xhr = new XMLHttpRequest();
                }
                else {
                    xhr = ActiveXObject("XMLHttpRequest");
                }
                //ie5 和ie6是activeobject;
                //请求方式,地址,是否异步;
                //xhr.open("get", "../Handler/test.ashx", true);
                xhr.open("post", "../Handler/test.ashx", true);
                //发送请求
                //设置请求的头部;
                xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                //xhr.send();
                xhr.send("a=3&b=4");
                xhr.onreadystatechange = function (data) {
                    if (xhr.readyState == 4) {
                        alert(xhr.responseText);
                    }
                };
            }

  • 相关阅读:
    CentOS6.4安装OpenSSL
    Linux下设置Tomcat开机启动
    Linux下Tomcat8.0.44配置使用Apr
    CentOS6.4将MySQL5.1升级至5.5.36
    Linux下实现MySQL数据库自动备份
    Linux将MySQL数据库目录挂载至新数据盘
    MySQL创建数据库与创建用户以及授权
    Node.js Mongoose数据库连接失败 提示:Authentication failed
    JBoss7.1.1远程无法访问
    mongodb3.4 远程连接认证失败
  • 原文地址:https://www.cnblogs.com/guozefeng/p/3467467.html
Copyright © 2020-2023  润新知