• ajax快记


    <html>
    <head>
    <script>
    function loadXMLDoc() {
       var xmlhttp;
      if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();                             
      } else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }                                                                                       //根据不同浏览器获得不同的xmlhttp对象
      xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
      }
     }                                                                   //达到一定的条件执行回调函数,因为每次readyState 的改变都会触发onreadystatechange 事件
      xmlhttp.open("POST", "ajaxservlet?time=" + new Date().getTime(), true);
      xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");//post请求的时候要这句话,为的就是将参数弄进url里面
      xmlhttp.send("a=2");
    }
    </script>
    </head>
    <body>
    <h2>My Book Collection:</h2>
    <div id="myDiv"></div>
    <button type="button" onclick="loadXMLDoc()">获得我的图书收藏列表</button>
    </body>
    </html>

    1.这里只记录一些学习笔记 2.这里只记录一些学习心得,如果心得方向有错,请留言 2.这里只记录一些日记(只为提升英语,暂时有点忙,等转行了开始写)
  • 相关阅读:
    C语言第九节 函数指针
    C语言第七节 指针
    C语言第五节 函数
    C语言第六节 结构体
    C语言第四节 数组
    C语言第三节 循环结构
    C语言第二节 分支结构
    ARC、MRC混编
    Git 和 SVN之间的五个基本区别
    KZ--NSString、NSMutableString
  • 原文地址:https://www.cnblogs.com/liyang31tg/p/3484066.html
Copyright © 2020-2023  润新知