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>
  • 相关阅读:
    js正则表达式——数字校验
    php curl cookie 读写
    Java遍历所有网卡打印对应IP
    mysql 查看数据库大小
    执行mvn 报错 source-1.5 中不支持 diamond运算符
    php开学之环境搭建
    ubuntu漂亮主题
    CleanAop使用笔记
    python学习笔记(五)
    python学习笔记(四)
  • 原文地址:https://www.cnblogs.com/52-it/p/4544754.html
Copyright © 2011-2022 走看看