본문 바로가기
프론트기술/JavaScript

JQuery -> Ajax 정리

by RevFactory 2012. 5. 3.

var get_humor_view = function ( content_id ){
//alert(content_id);
$.ajax({
type : "POST" ,
async : true ,//비동기
url : "/" ,
dataType : "html" ,//받는 데이터형식
cache : false ,//캐쉬처리
data : { //넘기는데이터
module : "popup" ,
sub : "ajax_humor" ,
//entities : entities ,
content_id : content_id
} ,
contentType : "application/x-www-form-urlencoded; charset=UTF-8" ,//문자셋설정
error : function(request, status, error){
//alert("code : " + request.status + "\r\nmessage : " + request.reponseText);
//alert("데이터 호출이 완료되지 않았습니다.\r\n다시 시도해 주시기 바랍니다.");
} ,
success : function(response, status, request) {//성공적으로 되었을시

//alert(response);
$("#complete_div").html(response);

} ,
beforeSend : function(){//보내기전 실행하는 함수
$('#loading_div').css("display","block");
$('#complete_div').css("display","none");
} ,
complete : function(){//데이터를 받아온후 실행하는 함수
$('#loading_div').css("display","none");
$('#complete_div').css("display","block");
$('#complete_div img').css("width","200px");
}
});
}

<a href="#" onclick='get_humor_view("{.content_id}");'>{.content}</a>

 

'프론트기술 > JavaScript' 카테고리의 다른 글

Json - Object 간 변환  (0) 2013.05.28
JQuery 객체에 메서드 추가하기  (0) 2013.04.11
JSON Object 와 String 간 변환  (0) 2013.01.05