반응형
반응형
반응형



ajax 로 array data request 시 서버에서 받는 방법.



var a = [];

a[0] = 1;

a[1] = 2;

a[2] = 3;


$.ajax({


url : "/test.json",

type : "POST",

data: {

'array_data' : a

},

dataType: 'json',

success: function(data) {

},

error: function(data, status, err){

}

});





Spring 에서 요렇게 받을수 있다.

@RequestParam(value = "array_data[]", required = false) List<String> arrayData


sprint 3.x, jquery 1.10.x




반응형
반응형

function ajax_call() {
        if (window.XMLHttpRequest) {
                // code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
        } else {
                // code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange=function() {
                if(xmlhttp.readyState==4 && xmlhttp.status==200) {
                        var resp = xmlhttp.responseText;
                        alert(resp);
                }
        }

        // Method, URL, 비동기처리
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);

        // Post 방식은 다음과 같이 사용.
        //xmlhttp.open("POST", url, true);
        //xmlhttp.send(param);
}

반응형

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

jquery crossdomain ajax jsonp  (1) 2015.10.30
한글, 영문 check  (0) 2011.12.27
숫자 입력 체크.  (0) 2011.11.29
trim  (0) 2010.11.19
reload (refresh)  (0) 2010.03.23
반응형

ajax 는 utf-8 통신.

자바스크립트에서 post 로 넘겨야됨.

sack 사용 시.

ex)

var description = description.value;

// sack 생성.
objSack = new sack();

// set variable(post)
objSack.setVar("description", description);


이렇게 하면 되네~

그리고 받는 쪽에서는..

request.setCharacterEncoding("utf-8");

요렇게 해줘야겠징..ㅋㅋ

^^

성공~~


반응형

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

quartz 사용시 UserTransaction 에러 발생시 해결.  (0) 2009.06.18
abstract 와 interface 의 차이.  (0) 2009.06.05
서블릿 설정  (0) 2009.04.09
[xml] xml parsing - SAXParseException  (0) 2009.03.13
inputStream <-> String  (0) 2009.03.03
반응형

XMLHttpRequest 는 UTF-8 통신이다.


==================================

server 가 php 일때...

server file 에서..

header("content-type:text/xml; charset=utf-8");
header("Cache-Control:no-cache");
header("Pragma:no-cache");

추가한다.

client 에 response 할때 iconv 를 이용해서 euc-kr 을 utf-8 로 인코딩해서 전달한다.

반응형

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

파일 크기 구하기(단위별)  (0) 2009.02.11
form 에서 method get 안될때..  (0) 2009.02.11
require 와 include 의 차이점  (0) 2009.02.06
정규표현식  (0) 2009.02.06
어제 날짜 구하기  (0) 2009.02.06

+ Recent posts