zoukankan      html  css  js  c++  java
  • 第六十天 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>
  • 相关阅读:
    echarts模拟highcharts实现折线图的虚实转换
    Chrome开发者工具详解 (5):Application、Security、Audits面板
    Chrome 开发者工具详解(4):Profiles 面板
    Chrome开发者工具详解(3):Timeline面板
    Chrome 开发者工具详解(2):Network 面板
    Chrome开发者工具详解(1):Elements、Console、Sources面板
    移动前端开发之 viewport 的深入理解
    响应式图片
    JS中的函数节流
    总结oninput、onchange与onpropertychange事件的用法和区别 书写搜索的神奇代码
  • 原文地址:https://www.cnblogs.com/52-it/p/4544754.html
Copyright © 2011-2022 走看看