ajax을 이용한 메뉴만들기
본문
답변 2
<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>
<div style="float:left;width:50px;background-color:색깔" id="div01">1