zoukankan      html  css  js  c++  java
  • javascript中最简单Ajax实例

        <script type="text/javascript" language="javascript">
            function show() {
                var xmlhttp;
                if (window.XMLHttpRequest) {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp = new XMLHttpRequest();
                }
                else {// code for IE6, IE5
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.open("GET", "index.ashx", true);
                xmlhttp.send();
    
                //readyState状态                                 
                //0: 请求未初始化                               
                //1: 服务器连接已建立 
                //2: 请求已接收 
                //3: 请求处理中 
                //4: 请求已完成,且响应已就绪 
    
                //status状态 
                //200: "OK"
                //404: 未找到页面
                xmlhttp.onreadystatechange = function () {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        document.getElementById("mydiv").innerHTML = xmlhttp.responseText;
                    }
                }
            }
        </script>
    
  • 相关阅读:
    TCP 基础知识
    Spring Boot 实战 —— 日志框架 Log4j2 SLF4J 的学习
    MySQL 实战笔记
    Java 基础
    RPM 包的构建
    RPM 包的构建
    9. 桶排序
    8. 基数排序
    7. 计数排序
    6. 快速排序
  • 原文地址:https://www.cnblogs.com/tangxueyang/p/2829239.html
Copyright © 2011-2022 走看看