zoukankan      html  css  js  c++  java
  • ajax中后台string转json

    首先导入alibaba的fastJson包

    后台:

    String thirdPage1=prop.getProperty("thirdPage1");
    String thirdPage2=prop.getProperty("thirdPage2");
    Map<String,String>map=new HashMap<>();
    map.put("thirdPage1", thirdPage1);
    map.put("thirdPage2", thirdPage2);
    String json=JSON.toJSONString(map);
    pw.print(json);
    

    前端:

    <script type="text/javascript">
    $(function(){
    	var lanaguage1=$('input:radio:checked').val();
    	$.ajax({
    		dataType:"json",
     		type:"post", 
     		url : "LanguageServlet?page=firstPage",
     		success : function(result) {
     			$("#firstPage1").html(result.firstPage1);
     			$("#firstPage2").val()=result.firstPage2;
     		}
     		}); 
     });
    </script>
    
  • 相关阅读:
    HDU 4801 Pocket Cube
    HDU 5008 Boring String Problem(后缀数组+二分)
    2-Sat问题
    后缀数组
    树形DP
    图论
    SRM 628 DIV2
    组合博弈
    Github使用笔记
    VS2010+OpenCV配置
  • 原文地址:https://www.cnblogs.com/hts-technology/p/7237685.html
Copyright © 2011-2022 走看看