這是我第一次嘗試做一些加載頁面與AJAX的東西。jQuery的功能停止與頁面加載與AJAX
這是工作正常幾頁,但與幻燈片或另一個jquery函數,腳本停止工作,我看到一些關於我需要再次調用函數,但我不知道我的代碼是在哪裏正確的地方,就像我需要調用加載頁面。
有我的JavaScript代碼
$(document).ready(function(){
preload([
'/img/bg_body_topo.jpg',
'/img/img_topo.png',
'/img/logo_topo.png'
]);
$("a[rel*=outside]").attr("target", "_blank");
$('#scrollbar').tinyscrollbar({ sizethumb: 55 });
$('#menu-topo ul li ul').hide();
$('#menu-topo ul li').hover(function(e) {
$(this).find('ul').stop().fadeToggle("fast");
});
$("#home-slide-destaques").scrollable({ circular: true }).autoscroll({ autoplay: true }).navigator(".controles");
// DISCOGRAFIA
$("ul#int-abas-discografia").tabs("div#int-conteudo-discografia > div", { effect: 'fade' });
// INTEGRANTES
$("ul#int-abas-integrantes").tabs("div#int-conteudo-integrantes > div", { effect: 'fade' });
var content = $('#content');
//pre carregando o gif
loading = new Image(); loading.src = '/img/103.gif';
$('#menu-topo a, a#menu-ajax').live('click', function(e){
e.preventDefault();
var tHeight = $('#wrapper').height();
var tWidth = $('#wrapper').width();
var posicao = $('#wrapper').position();
$('#carregando').remove();
$('#imgcarregando').remove();
$('#wrapper').prepend('<div id="carregando"></div> <div id="imgcarregando"> <img src="/img/103.gif" style="margin:280px 0 0 0;" alt="Carregando"/></div>');
$('#carregando').css({
'position': 'absolute',
'width': tWidth,
'height': tHeight,
'top': posicao.top,
'left': posicao.left,
'background': '#000',
'opacity': '.60',
'z-index': '9900',
'text-align': 'center'
});
$('#imgcarregando').css({
'position': 'absolute',
'width': tWidth,
'height': tHeight,
'top': posicao.top,
'left': posicao.left,
'background': '#000 url(/img/logo_topo.png) center 200px no-repeat',
'padding': '30px 0 0 0 ',
'opacity': '.88',
'z-index': '9999',
'text-align': 'center'
});
content.html('');
var href = $(this).attr('href');
$.ajax({
url: href,
success: function(response){
//forçando o parser
var data = $('<div>'+response+'</div>').find('#content').html();
//apenas atrasando a troca, para mostrarmos o loading
window.setTimeout(function(){
content.fadeOut('slow', function(){
$('#carregando').fadeOut('slow');
$('#imgcarregando').fadeOut('slow');
$('#content').height('auto');
// DESTAQUES
content.html(data).fadeIn();
});
}, 1000);
}
});
});
});
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
// Alternatively you could use:
// (new Image()).src = this;
});
}
您是否嘗試過使用JavaScript調試器,如google chrome has或firebug? – derabbink 2013-02-10 21:29:40
嗨@derabbink我打開網頁一切工作正常,我去任何鏈接,並打開網頁罰款,但如果我走在任何JavaScript函數的內部頁面只是不工作,像一張幻燈片的頁面。在JavaScript控制檯上不顯示任何錯誤 – 2013-02-10 21:33:31