• 第六十天 how can I 坚持


      贴点自己的代码吧。

      AJAX提交后台json代码,获取返回值。

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    <script type="text/javascript">
    function test(){
    alert("dafadsfa");
    var xmlHttp;
    if(window.XMLHttpRequest){
        xmlHttp=new XMLHttpRequest();
    }
    else if(window.ActiveXObject){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    var saveJson='{'
        +'    "productInfo": {'
        +'        "insured_count": "1",'
        +'        "productPrice": "45",'
        +'        "startDate": "2015-05-31 00:00:00",'
        +'        "endDate": "2015-05-31 23:59:59",'
        +'        "productName": "测试产品",'
        +'        "showPeriod": "1D",'
        +'        "productId": "203401010",'
        +'        "productApp": "|00000000000000003476_Period=1D|00000000000000003475_TextAge=0Y-80Y|'
        +'00000000000000003483_Mult=1|00000000000000003484_AppDate=2D",                               '
        +'        "productDuty": "",                                                                 '
        +'        "shareId": ""                                                                      '
        +'    },                                                                                     '
        +'    "SDInformationAppnt": [                                                                '
        +'        {                                                                                  '
        +'            "applicantName": "尚小梅",                                                        '
        +'            "applicantIdentityTypeName": "身份证号码",                                          '
        +'            "applicantIdentityId": "",                                   '
        +'            "applicantMail": "",                                           '
        +'            "applicantMobile": ""                                               '
        +'        }                                                                                  '
        +'    ],                                                                                     '
        +'    "SDInformationInsured": [                                                              '
        +'        {                                                                                  '
        +'            "recognizeeName": "尚小梅",                                                       '
        +'            "recognizeeIdentityTypeName": "身份证号码",                                         '
        +'            "recognizeeIdentityId": "",                                  '
        +'            "recognizeeMobile": "",                                             '
        +'            "flightTime": "2015-07-19",                                  '
        +'            "recognizeeMail": "",                                          '
        +'            "isSelf": "Y",                                                                  '
        +'            "recognizeeBirthday": ""                          '
        +'        }                                                                              '
        +'    ],                                                                                     '
        
        +'    "SDInformationProperty": [                                                             '
        +'        {                                                                                  '
        +'            "remark1": ""                                                                  '
        +'        }                                                                                  '
        +'    ]                                                                                      '
        +'}                                                                                          ';
        xmlHttp.onreadystatechange=function()
          {
          if (xmlHttp.readyState==4 &&xmlHttp.status==200)
            {
            document.getElementById("myDiv").innerHTML=xmlHttp.responseText;
            }
          }
        //配置XMLHttpRequest对象
            xmlHttp.open("post", "../../shop/wap_order!saveOrdersInfo.action",true);
            //xmlHttp.open("post", "http://219.141.188.60:9080/shop/wap_order!saveOrdersInfo.action",true);
            xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
            //发送请求
            xmlHttp.send("saveJson="+saveJson);
    }
    </script>
    </head>
    <body>
    <input type="button" value="提交" onclick="test()">
    <div id="myDiv"/>
    
    </body>
    </html>
  • 相关阅读:
    前端资源
    WCF常见异常-The maximum string content length quota (8192) has been exceeded while reading XML data
    Asp.Net MVC路由调试工具-RouteDebugger
    Java中String 的equals 和==详解
    记一次高级java工程师职位的面试
    java中Class对象详解和类名.class, class.forName(), getClass()区别
    2014读书计划
    Javascript quiz
    CSS3 Flexbox布局那些事
    前端开发中的图片优化
  • 原文地址:https://www.cnblogs.com/52-it/p/4544754.html
Copyright © 2020-2023  润新知