zoukankan      html  css  js  c++  java
  • 纯手写ajax

    function loadAsyncData(url, id) {
        var xmlhttp;
        if (!url || !id) {
            return;
        }
        domId = id;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (xmlhttp != null) {
            try {
                xmlhttp.onreadystatechange = function() {
                    if (xmlhttp.readyState == 4) {// 4 = "loaded"数据接收完毕,此时可以通过通过responseBody和responseText获取完整的回应数据
                        if (xmlhttp.status == 200) {// 200 = "OK"
                            document.getElementById(id).innerHTML = xmlhttp.responseText;
                        }
                        else {
                            document.getElementById(id).innerHTML = ''; //default ad
                        }
                    }
                }


                xmlhttp.open('GET', url, true);

                xmlhttp.send(null);


            } catch (e) {
                alert(e);
            }
        }
        else {
            alert("Your browser does not support XMLHTTP.");
        }
    }
    function aa() {
        loadAsyncData("Hand.ashx?id=" + document.getElementById('Text1').value, "hh");
        document.getElementById("hh").style.display = "block";
    }
  • 相关阅读:
    ORACLE触发器详解
    论文笔记 Interpreting Black-Box Classifiers Using Instance-Level Visual Explanations
    Popush迭代2个人总结
    Popush迭代1个人总结
    Popush第5次会议记录
    Xv6代码阅读报告之进程调度
    Popush源代码学习报告
    Popush 第二次小组会议记录及分工
    Popush 用户故事
    “老衲印象”开发团队章程
  • 原文地址:https://www.cnblogs.com/lilyzhang/p/1585084.html
Copyright © 2011-2022 走看看