IT 소식

 

 

 

 

datatype : 'local' 로 설정후에 ajax 를 실행하면 데이터를 불러온다

 

 

'프로그래밍 > Grid 공통' 카테고리의 다른 글

JqGrid Json 데이터 불러오기  (0) 2018.02.12

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  @RequestMapping(value = "/test6.do", method = RequestMethod.POST)
  @ResponseBody
  public String test6(){
     
    JSONObject jsonObject = new JSONObject();
    JSONArray listData = new JSONArray();
    JSONObject listInfo = new JSONObject();
 
    // 정보 입력
    listInfo.put("SEQ", "송강호");
    listInfo.put("TITLE", "남자");
    listInfo.put("INSERT_TIME", "25");
    listInfo.put("INSERT_ID", "남궁민수");
    listInfo.put("READ_COUNT", "1");
    // Array에 입력
    listData.add(listInfo);
 
    listInfo = new JSONObject();
    listInfo.put("SEQ", "송강호");
    listInfo.put("TITLE", "남자");
    listInfo.put("INSERT_TIME", "25");
    listInfo.put("INSERT_ID", "남궁민수");
    listInfo.put("READ_COUNT", "1");
    listData.add(listInfo);
 
    // 전체의 JSONObject에 사람이란 name으로 JSON의 정보로 구성된 Array의 value를 입력
    jsonObject.put("page", "1");
    jsonObject.put("total", "2");
    jsonObject.put("listData", listData);
 
    String jsonInfo = jsonObject.toString();
    System.out.println("jsonInfo:" + jsonInfo);
 
    return jsonInfo;
  }
<p style="FLOAT: none; TEXT-ALIGN: center; CLEAR: none"> </p><p> </p>

'프로그래밍 > Grid 공통' 카테고리의 다른 글

JqGrid Ajax 데이터 불러오기  (0) 2018.02.13

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
<form id="fm" name="fm" method="post">
<input type="hidden" name="userId" id="userId" value="test1234">
<input type="hidden" name="userPass" id="userPass" value="pass1234">
축구:<input type="checkbox" name="type" id="type" value="축구">
야구:<input type="checkbox" name="type" id="type" value="야구">
농구:<input type="checkbox" name="type" id="type" value="농구">
</form>
<button onclick="goAjax1();">goAjax1</button>
<button onclick="goAjax2();">goAjax2</button>
<button onclick="goAjax3();">goAjax3</button>
<button onclick="goAjax4();">goAjax4</button>
<button onclick="goAjax5();">goAjax5</button>
<button onclick="goAjax6();">goAjax6</button>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function goAjax6(){
   
  var checkValues = new Array();
  $("input[name='type']:checked").each(function(){
    checkValues.push($(this).val());
  });
   
  var data = {"userId": $("#userId").val(), "userPass":$("#userPass").val(), "type":checkValues };
   
  $.ajax({
    type: "POST",
    url : "<c:url value="/goAjax6.do">",
    data : JSON.stringify(data),
    dataType: "json",
    contentType:"application/json;charset=UTF-8",
    async: false,
    success : function(data, status, xhr) {
      console.log(data);
    },
    error: function(jqXHR, textStatus, errorThrown) {
      alert("error= " + errorThrown);
    }
  });
}
</c:url>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  /**
   * @param JSON 데이터 받기
   * @return
   * @throws Exception
   */
  @RequestMapping(value = "/goAjax6.do", method = RequestMethod.POST)
  @ResponseBody
  public Map<string, object=""> goAjax3(@RequestBody String param) throws Exception{
     
    JSONObject json = JSONObject.fromObject(param);
    System.out.println("userId:"+json.get("userId"));
    System.out.println("userPass:"+json.get("userPass"));
    System.out.println("type:"+json.get("type"));
     
    JSONArray array = (JSONArray) json.get("type");
    for(int i=0; i<array.size(); i++){="" system.out.println("array:"+array.get(i));="" }="" map<string,="" object=""> map = new HashMap<string, object="">();
    map.put("AA", "1");
    map.put("BB", "2");
    return map;
  }
 
</string,></array.size();></string,>

'프로그래밍 > Spring' 카테고리의 다른 글

Ajax JSON Map 타입으로 넘기고 받기  (0) 2018.01.30
전자정부 프레임워크 Ajax 설정  (0) 2018.01.09
Spring properties 설정방법  (0) 2017.10.26