zoukankan      html  css  js  c++  java
  • 支持自定义回调函数的异步调用

        做一个最简单的POST方式异步调用的请求,支持自定义的回调函数,该回调函数获取异步请求返回的XMLDOM对象,代码如下:

    function postRequest(url,parameters,callBack){
        
    var xmlHttp = getXmlHttp(); //create xmlHttpRequest
        if(xmlHttp !=null){
            xmlHttp.onreadystatechange 
    = function(){
                
    if(xmlHttp.readyState == 4){
                    
    if(xmlHttp.status == 200){
                        xmlDom 
    = getXmlDom(xmlHttp.responseText);//create xmlDom
                        
    if(xmlDom != null){
                            eval(callBack(xmlDom));
                        }
                    }
                }
            }
            xmlHttp.open(
    'Post',url,true);
            xmlHttp.setRequestHeader(
    "Content-Length",parameters.length);
            xmlHttp.setRequestHeader(
    "Content-Type","application/x-www-form-urlencoded");
            xmlHttp.send(parameters);
        }
    }

  • 相关阅读:
    k8s 1.10 部署springcloud
    TF-IDF关键词提取步骤
    k8s 离线安装
    JWT对SpringCloud进行系统认证和服务鉴权
    centos7 安装 docker-registry
    Docker安装elasticsearch-head监控ES步骤
    tengine 配置应用防火墙
    elasticsearch6.1.3 集成分词器
    centos7 nginx tengine 安装
    elk 搭建
  • 原文地址:https://www.cnblogs.com/BeanHsiang/p/1107080.html
Copyright © 2011-2022 走看看