본문 바로가기

Local Oriented/jQuery

[모음글] jQuery ajax

$.ajax({ url : '...', // 변수를 이용해서 url 설정 가능, Math.random() 를 파라미터로 넣어줌으로써 캐시 제거 가능

global : false, // Default true, 또는 생략 type : 'post', // 또는 get cache : false, // Default true, 캐시를 사용하지 않으려면 false 요망 data : {curData:curDate, to_date2:to_date2}, // JSon 스타일 //data : 'curData='+curDate+'&to_date2='+to_date2', // String 스타일. $('form').serialize() 코드는 간단하지만.. dataType : 'stirng', // json jsonp xml html text 중 선택. 차후 암호화나 압축방식이 나와야 한다고 생각되네요. contentType : 'application/x-www.form-urlencodede;charset=UTF-8', async : false, // Default true, dataType 이 jsonp 인 경우 false 불가. 또는 생략 clearForm : true, // default(생략) false; 값을 넘긴 다음 form 안에 있는 값들을 리셋한다는 얘기 같은데.. 글쎄요..

timeout:1000, // mili-seconds 단위. 또는 생략 success : function(xml){ // xml 이건 data 건.. dataType 에 기술된 Type 에 맞춰진 데이타 var $str_title = ""; $(xml).find("row").each(function(){ var title = '<p>'+ $(this).find("vdsnm").text() +'&nbsp&nbsp'+$(this).find("jqty").text() +'&nbsp&nbsp'+$(this).find("SQTY").text()+'</p>'; $str_title = $str_title + title; }); $(".table").html($str_title); }, error:function(response, textStatus, errorThrown){

//예를들어 404 FileNotFound 이면, response.status 404, textStatus error, errorThrown Not Found }, beforeSend:function(){ // check valid } });

- jquery 로 json 을 사용하는 방법 2가지, $.ajax 와 $.get

- jQuery 와 Java 로 XML DOM 다루기

- http://hyeondatasource.blogspot.kr/2013/07/jquery-jquery-66-ajax.html ajax 관련 함수 밑 속성

o References - http://dever.tistory.com/207



o 에러처리

http://www.maheshchari.com/jquery-ajax-error-handling/