2012-03-04 63 views
-2

好的,我有一個ajax腳本。 它與jQuery 1.4.4和jQuery地址1.3.2結合在一起。 基本上,我希望它淡入淡出div而不是現在改變它。我希望它看起來更加流暢。使用jQuery褪色AJAX

這是AJAX:

jQuery.noConflict() 

if(window.location.hash == "") { 
    window.location.href = "#home"; 
} 

jQuery(document).ready(function(event) { 

    jQuery.address.change(onAddressChange); 

    jQuery('a[href=' + window.location.hash + ']').addClass('selected'); 

    jQuery('a[rel=ajax]').click(function (evt) { 
    evt.preventDefault(); 

    var hash = evt.target.href; 
    hash = hash.replace(/^.*#\//, ''); 
    jQuery.address.value(hash); 

    jQuery('#content').hide(); 
    jQuery('.loading').show(); 
    }); 
}); 

// Handles forms 

$('form').live('submit', function() { 

     var hash = window.location.hash.replace('#', ''); 
      hash = $.browser.mozilla ? hash : decodeURIComponent(hash); 

     if($(this).attr('action') == '') $(this).attr('action', hash); 

     $(this).append('<input type="hidden" name="submit" value="submit" />'); 

     var data = $(this).serialize(); 

     $.post('loader.php?page=' + $(this).attr('action'), data, function(response, status) { 

      if(status == 'error') return false; 

      $('#content').html(response); 

     }); 

     return false; 

    }); 

// End forms 

function onAddressChange(evt) { 
    var page = evt.value.replace(/[#!\/]/, ''); 

    jQuery('a[rel=ajax]').removeClass('selected'); 
    jQuery('#'+page).addClass('selected'); 

    var data = 'page=' + encodeURIComponent(page); 
    jQuery.ajax({ 
    url: "loader.php", 
    type: "GET", 
    data: data, 
    cache: false, 
    success: function (html) { 
     jQuery('.loading').hide(); 
     jQuery('#content').html(html); 
     jQuery('#content').fadeIn('slow'); 
    } 
    }); 
} 

我不代碼JS。這是由一位朋友提供給我的。所以如果有人可以讓我淡入淡出,我會感激不盡。

如果你需要它:www.julake.co.uk/staff/media_123

這是一個工作示例:www.44lizards.com/ajaxcodedrop

回答

0

CBA去了那個可怕編寫的代碼,但我猜你可以用.fadeIn(300)和.fadeOut(300)替換「.show()」和「.hide()」,它會在0.3秒的時間內淡入/淡出。

所以.fadeIn用於顯示,.fadeOut用於隱藏。

+0

沒有。仍然沒有這樣做。 – futureslay 2012-03-04 18:47:34