채택완료

ajax을 이용한 메뉴만들기

2015-12-11 (금) 12:38:22 5,228

아래처럼 ajax를 이용해 버튼클릭하면 체크되고 컨텐츠 로딩되게

 만들고 싶습니다. 예저나 소스좀 링크부탁드립니다.

76230524e0c925cf7606566473eaa05c_1449805010_4813.jpg
 

|

답변 2개 / 댓글 2개

채택된 답변
+20 포인트

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.js"></script>

<div style="float:left;width:50px" id="div01">111</div>

<div style="float:left;width:50px"  id="div02">222</div>

<div style="float:left;width:50px"  id="div03">333</div>

<div style="clear: both;"  id="div04">4444</div>

<script type="text/javascript">

<!--

$('#div01').click(function (e) { 

$.ajax({

type : 'post',

url : "./test.html",

data : {"data1" : "aaaa", "data2" : "bbbb"},

success : function(res){

if( res ){

jQuery("#div04").html(res);

}else{

}

},

error : function () {

}

});

});

$('#div02').click(function (e) { 

$.ajax({

type : 'post',

url : "./test2.html",

data : {"data1" : "aaaa", "data2" : "bbbb"},

success : function(res){

if( res ){

jQuery("#div04").html(res);

}else{

}

},

error : function () {

}

});

});

$('#div03').click(function (e) { 

$.ajax({

type : 'post',

url : "./test3.html",

data : {"data1" : "aaaa", "data2" : "bbbb"},

success : function(res){

if( res ){

jQuery("#div04").html(res);

}else{

}

},

error : function () {

}

});

});

//-->

</script>

답변에 대한 댓글 1개

선택버튼의 색갈변화는 어떻게 해야 할까요?

<div style="float:left;width:50px;background-color:색깔" id="div01">1 

답변에 대한 댓글 1개

그렇게 해버리면 계속 고정되어 버리지 않나요? 2번을 선택하면 2번에빨간색 들어오게 하고 싶거든요

답변을 작성하려면 로그인이 필요합니다.