Php jqueryajax问题与div刷新和新内容

Php jqueryajax问题与div刷新和新内容,php,jquery,ajax,Php,Jquery,Ajax,我想用发送到calendar.php的新内容刷新#calendardiv 我收到一个成功警报,但内容没有刷新。如何让新的calendar.php显示发布的数据 $(document).ready(function(){ $('#next').click(function() { $.ajax({ type: "POST", url: "calendar.php", data: 'year=2012', target: '#calend

我想用发送到calendar.php的新内容刷新
#calendar
div 我收到一个成功警报,但内容没有刷新。如何让新的calendar.php显示发布的数据

$(document).ready(function(){
 $('#next').click(function() {
  $.ajax({
       type: "POST",
       url: "calendar.php",
       data: 'year=2012',
       target: '#calendar',
       success: function(html){
          alert("Success");

       }
     });
   });
相关的HTML代码如下所示:
#next
是calendar.php中div标记上的id

<div id="calendar">
    <?php include('calendar.php'); ?>
</div><!-- /#calendar -->

您可以在处理程序中显式设置它:

success : function (html) {
    $('#calendar').html(html);
}

此外,由于您将替换calendar div的内容(其中包含
#next
链接),您可能需要使用
.live('click',function(){
)而不是
。click(function()
),因为您将丢失事件处理程序。

$('#next').click(function(){

    $('#calendar').load('calendar.php', {year: 2012}, function(){

        // The response html was loaded into the calendar div already
        // You could use this area to display a success message
        alert("Done!");

    });

});