zoukankan      html  css  js  c++  java
  • HTMLPage测试js通过ajax调用

    HTMLPage测试js通过ajax调用接口

    <!DOCTYPE html>
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script type="text/javascript">
            var Json=json="{
      "head": {
        "xzqdm": "320801",
        "wdbs": "320801001"
      },
      "data": {
        "ywbh": "32101412123",
        "jdmc": "受理",
        "myd": "2",
        "pjsj": "2019-10-30 10:22:36",
        "blry": "张三",
        "sqrxm": "李四",
        "sqrlxfs": "18888888888"
      }
    }";
    
            var XMLHttpReq;
    
            function createXMLHttpRequest() {
                try {
                    XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); //IE高版本创建XMLHTTP
                }
                catch (E) {
                    try {
                        XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); //IE低版本创建XMLHTTP
                    }
                    catch (E) {
                        XMLHttpReq = new XMLHttpRequest(); //兼容非IE浏览器,直接创建XMLHTTP对象
                    }
                }
            }
    
            function sendAjaxRequest(url) {
                alert(url);
                var json;
                createXMLHttpRequest();
                XMLHttpReq.open("post", url, false);
                XMLHttpReq.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
                XMLHttpReq.onreadystatechange = function () {
    
                alert(XMLHttpReq.readyState+ XMLHttpReq.status);
    
                if (XMLHttpReq.readyState == 4) {
                        if (XMLHttpReq.status == 200) {
                           json = eval("(" + XMLHttpReq.responseText + ")");  
                       }
                    }
                }
                XMLHttpReq.send(encodeURIComponent(json));
                return json;
            }
        </script>
    </head>
    <body>
        <input id="Button1" type="button" onclick="sendAjaxRequest('http://192.168.1.188:8080/api/v1/evaluate')" value="button" />    
    </body>
    </html>
  • 相关阅读:
    CNN comprehension
    Gradient Descent
    Various Optimization Algorithms For Training Neural Network
    gerrit workflow
    jenkins job配置脚本化
    Jenkins pipeline jobs隐式传参
    make words counter for image with the help of paddlehub model
    make words counter for image with the help of paddlehub model
    git push and gerrit code review
    image similarity
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/11770896.html
Copyright © 2011-2022 走看看