2012-03-04 75 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