2012-09-26 5 views
0

저는 calendar.php에서 달과 해를 얻는이 스크립트를 만들었고 이전 달을 얻기 위해 지난 달 링크를 클릭 할 때뿐만 아니라 달 번호가 1에 도달 할 때도 싶습니다. 1 년 - 1. 나는 어떻게 그렇게 할 수 있을까?jQuery는 PHP에서 지난 달 가져 오기

<html> 
<head></head> 


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> 
<script> 
$(function() { 
get_data(); 
}); 

function get_data(a, b) { 

$.get('calendar.php', { 
    month: a, year: b 
    }, 

    function(response) { 
    $el = $('<div></div>').attr('class', 'data').html(response); 
    $('#datas').prepend($el); 
    height = $el.height()+'px'; 
    $el.css({'opacity': 0, 'display': 'block', 'height': '0px'}).animate({height: height }, 500, function() { 
      $(this).animate({opacity: 1}, 500); 
    }) 
}); 
} 
    </script> 
<style> 
#datas { 
overflow: hidden; 
} 
.data { 
display: none; 
} 
</style> 
<body> 
<a href="#" OnClick="get_data(9, 2012);" > Previous month</a> 
<div id="datas"> 
</div> 
</body> 
</html> 
+1

을 사용할 수 있습니다 yerstaday 얻기 위해 jQuery.ajax

$.ajax({ url: 'calendar.php', success: function(data) { // Parse your data and do all neccessery refreshing } }); 

를 사용한다고 생각, 방지 할 JS 라이브러리의 많음이있다 당신은 간단한 작업을 위해 서버 호출을하기위한 것입니다. – moonwave99

+0

도서관의 예를 들어 주시겠습니까? – Netra

답변

1

나는 당신이 마야 달력을 취급하지 않는 당신이

var d = new Date(/* data that you get from calendar.php*/); 
d.setDate(d.getDate() - 1);