2012-01-16 25 views
2

jquery ".load" functinを使用して、画像がロードされるまで「フェードイン」を遅らせます。 しかし、それはすべてのブラウザで正常に動作しています。ちょうどIEが問題を起こしています - それはキャッシュです...これまでのところ私は問題を理解しました...しかしそれを解決する方法は?この問題を解決するプラグインはありますか?ここjquery .load関数、IEでのキャッシュエラー

コード例:

この例では
// this is the user thumbnail, which will be loaded from the database, with a random number as filename. 
if (thumb_medium == '1') { 

    // create picture link. 
    var pic = Math.floor(Math.random() * (1000000)); 
    var image_link = "image/image_show.php?id=" + id + "&element=image_profile_thumb_medium" + "&pic=" + pic + '.jpg'; 

    // write the picture link to the src attr. 
    $('#brpr_list_thumb_' + tuple).attr('src', image_link); 
} 
else { 

    // male image - if there is no user picture in the database. 
    if (gender == 'male') { var image_link = "pic/icons/male_128_128.png" }; 

    // female image - if there is no user picture in the database. 
    if (gender == 'female') { var image_link = "pic/icons/female_128_128.png" }; 

    // write the link to the src attr. 
    $('#brpr_list_thumb_' + tuple).attr('src', image_link); 
} 


// when the loading process of the picture is finished a fadeIn happens - this makes problems in IE, but just with the male and female image, which get cached from IE. 
$('#brpr_list_thumb_' + tuple).load(function() { $('#brpr_list_thumb_' + tuple).fadeIn(250) }); 

、男性と女性のイメージがIEによってキャッシュなっていると、彼らが得る次回は、彼らが表示されませMEYロード..

何ですか!それを解決する最善の方法は?

答えて

0

画像URLにタイムスタンプを追加できます。試してみてくださいこの

あまりにも私のthaughtだった
if (thumb_medium == '1') { 

    // create picture link. 
    var pic = Math.floor(Math.random() * (1000000)); 
    var image_link = "image/image_show.php?id=" + id + "&element=image_profile_thumb_medium" + "&pic=" + pic + '.jpg'; 

    // write the picture link to the src attr. 
    $('#brpr_list_thumb_' + tuple).attr('src', image_link + "&t=" + (new Date()).getTime()); 
} 
else { 

    // male image - if there is no user picture in the database. 
    if (gender == 'male') { var image_link = "pic/icons/male_128_128.png" }; 

    // female image - if there is no user picture in the database. 
    if (gender == 'female') { var image_link = "pic/icons/female_128_128.png" }; 

    // write the link to the src attr. 
    $('#brpr_list_thumb_' + tuple).attr('src', image_link + "?t=" + (new Date()).getTime()); 
} 
+0

- そして実際に私は、データベースから読み込む画像をそのようにこの問題を解決しています...しかし、どのように私は、このリンクPIC /アイコン/ male_128_128にタイムスタンプを追加することができます.pngこのリンクに何かを追加すると、既存の画像が表示されませんか?または私はこれを完全に間違って理解していますか? – Andreas

+0

私の答えを見てください私はすでにあなたが参照している画像にタイムスタンプを追加しており、問題なく正常に動作します。 – ShankarSangoli

1

IEは非常に便利で、キャッシュはデフォルトでAjaxに戻ります!

正気な応答をしたい場合は、手動ですべてのajax要求をキャッシュしないように手動で設定できます。これをスクリプトの先頭に追加します。

$.ajaxSetup({ 
    cache: false 
}); 
関連する問題