码迷,mamicode.com
首页 > 其他好文 > 详细

第六十天 how can I 坚持

时间:2015-06-01 20:12:33      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

  贴点自己的代码吧。

  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>

 

第六十天 how can I 坚持

标签:

原文地址:http://www.cnblogs.com/52-it/p/4544754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!