2012-06-29 19 views
0

我有一個div,其中包含一些文章。當用戶點擊下一個按鈕時,我希望現有的文章向左滑動並讓下一頁文章滑入以替換它們。如何在成功的jQuery ajax調用時模仿數據的輪播刷新?

enter image description here

進出口尋找有我的結果左如果用戶如果用戶點擊<上一個鏈接在點擊右邊的>下一個環節或幻燈片幻燈片。 (有點像旋轉木馬)

下面是slideDown動畫的一個工作示例。

//Fetch the new result set. 
$.ajax({ 
    url: '/Home/_WhatsNew', 
    type: 'POST', 
    data: JSON.stringify(jsonData), 
    dataType: 'html', 
    contentType: 'application/json', 

    //The request was a success. Repopulate the div with new result set. 
    success: function (data) { 
     $("#Content").empty(); 
     $(data).hide().appendTo('#Content').slideDown(); 
    }, 
    error: function (data) { 
     alert('Fail'); 
    } 
}); 

是否有可能以旋轉木馬般的方式做到這一點?

+0

看看['animate'(HTTP:// API。 jquery.com/animate) –

回答

1

您可以使用jQuery UI slide effect

success: function (data) { 
    $('#Content') 
     .hide('slide', { direction: 'left' }, 400, function() { 
      $(this) 
       .html(result) 
       .show('slide', { direction: 'right' }, 400); 
     }); 
} 

只要爲jquery-ui-1.8.11.js腳本到您的網頁,並享受:

<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.js")" type="text/javascript"></script> 
+0

工作過,非常感謝您的幫助! – Maddhacker24