
Untitled
By: a guest on
Aug 10th, 2012 | syntax:
None | size: 1.58 KB | hits: 2 | expires: Never
Ajax: fade in new content only if its fully loaded
$(function(){
var replacePage = function(url) {
$.ajax({
url: url,
type: 'get',
dataType: 'html',
beforeSend: function() {
$(".menue").slideUp();
},
success: function(data){
var dom = $(data);
var html = dom.filter('#content').html();
$('#content').html(html);
},
complete: function(){
$("#content").fadeIn();
}
});
}
$('nav a').live('click', function(e){
history.pushState(null, null, this.href);
replacePage(this.href);
e.preventDefault();
$("#content").hide();
});
$(window).bind('popstate', function(){
replacePage(location.pathname);
});
});
success: function(data){
var dom = $(data);
var html = dom.filter('#content').html();
$(".menue").promise().done(function(){
$('#content').html(html).fadeIn()
})
},
$(".menue").slideUp('slow', function(){
$.ajax({
url: url,
type: 'get',
dataType: 'html',
success: function(data){
var dom = $(data);
var html = dom.filter('#content').html();
$('#content').html(html).fadeIn()
}
});
})
success: function(data){
var dom = $(data);
var html = dom.filter('#content').html();
$('#content').html(html).hide().fadeIn();
},