2013-04-26 31 views
2

我一直是一個很長的時間stackoverflow潛伏者,並幾乎總是找到我的問題在板上的答案(謝謝你),但這一個正在傾訴我...使用jQuery定位和PHP獲取URL時,圖像並不總是加載

我建立一個投資組合網站..它使用jQuery來定位從MySQL數據庫中拉出的元素(圖像)..非常簡單...但由於某種原因,圖像不'並不總會裝載或將裝載一對夫婦,然後永久地掛斷電話並沒有做任何事情......

頁是這裏... http://www.spacecar.org/2013/

做所有工作的JS文件在這裏 http://www.spacecar.org/scripts/jquery.menu.js

有沒有真正基本的東西我只是沒有看到?任何洞察力將非常感激......我知道我正在製作很多調用來制定網站的效果功能,但是...啊!

感謝

+1

認爲它有什麼與您的jQuery圖像加載器,名稱krioImageLoader – Pitchinnate 2013-04-26 19:12:03

+0

感謝您的答覆!我試圖刪除它,但不幸的是頁面沒有任何影響。圖像仍然不加載... – drasticdub 2013-04-26 19:23:50

+0

你是否得到了小負載微調或破碎的圖像? – Pitchinnate 2013-04-26 19:38:26

回答

0

$('img').load(function(){ ... }); - 是不是可以信任的東西(在你的插件我看到這個代碼)。在這裏,你可以看到爲什麼: http://api.jquery.com/load-event/(開始從caveats字讀)

下面是小例子來形容麻煩:

$(document).ready(function(){ 
    $('img').load(function(){ 
     // this event going to fire only if document was ready after image was loaded; (very seldom, almost never) 
     console.log('Fired?! You are lucky today!'); 
    }); 

    $(document.body).append('<img src="http://stat19.privet.ru/lr/0b164d8151948d2fdedfbfdc420f5392?temp=2" id="some"/>'); 
    $('#some').load(function(){ 
     // this event will fire often, except of cases descripted in `load` event manual 
     console.log('Huugh. Today have fired. But I don\'t know about tomorrow'); 
    }); 

    var temp = new Image; 
    temp.src = 'http://photo.a42.ru/photos/92772/medium/11757.jpg'; 
    temp.onload = function(){ 
     // this event going to fire almost always except of cache issue with IE, that can be handled by skipping cache with `?nothing=random` appending to image URL 
    console.log('Okay, okay! I\'ve fired'); 
    } 
    $(document.body).append(temp); 
}); 

你可以在這裏運行:http://jsfiddle.net/p6Cpy/

+0

謝謝大家幫我解決這個問題......它確實是圖像加載器......這裏的解決方案.. http://stackoverflow.com/a/8546076/2321573 ..似乎已經修復了一切...... – drasticdub 2013-04-30 21:35:20

相關問題