zoukankan      html  css  js  c++  java
  • Ajax.js

      原生js   Ajax的插件   将其封装起来

      function ajax(method,url,boo,fn){
        //创建Ajax的实例对象
        var xmlhttp=new XMLHttpRequest();
        //像后台发送请求
        xmlhttp.open(method,url,boo);
        //发送
        xmlhttp.send()
        //向服务器响应;
        xmlhttp.onreadystatechange=function(){
          if(xmlhttp.readyState==4 && xmlhttp.status==200){
            //说明与服务器发送响应也成功了
            fn(xmlhttp.responseText)
          }
        }
      }

      使用手册

      ajax("get","cont.txt",true,ff);
      function ff(data){
        var arr=JSON.parse(data);
        document.getElementById("div").innerHTML+=arr[0].name;
      }

  • 相关阅读:
    Netty
    HttpClient 该知道一些概念
    Hibernate QBC 简单收集
    IUAP--单点登录
    js图片压缩和上传并显示
    vue移动端项目
    js自定义滚动条
    mysql5.7以上版本安装
    学习webpack
    学习es6
  • 原文地址:https://www.cnblogs.com/shangjun6/p/10483438.html
Copyright © 2011-2022 走看看