コンテンツがまだdivにロードされていない場合にのみ、ajaxがロードされることを期待して、次のコードを記述しました。基本的に、ajaxを使用してコンテンツをロードし、現在ロードされているコンテンツに応じてコンテンツにクラス名を付ける場合。現在のクラス名がすでにdivにロードされているコンテンツである場合は、ajaxをロードしません。それ以外の場合は、ajaxを使用してコンテンツをロードします。
現在、divのクラス名に関係なくajaxリクエストが発生します。これが機能しない理由はありますか?
これがサイトです:(左目をクリックしてください)
http://www.uvm.edu/~areid/homesite/index.html
javascript関数は次のとおりです。
else if(id =='left-eye23')
{
leftcontent = $("#left-content");
content = leftcontent.attr('class');
if(content !== 'photos')
{
alert("content is not photos");
SlideOut(move);
$("#relativeContainer").css('z-index','-1');
var leftcontent;
$("#left").bind("webkitTransitionEnd mozTransitionEnd oTransitionEnd msTransitionEnd transitionend",
function(){
$.ajax({
url:'photos.php',
beforeSend: function(){
leftcontent.html('<img src="loading.gif" /> Now loding...');
},
}).done(function(data){
leftcontent.html(data);
leftcontent.addClass("photos");
});
});
}
else if(content == 'photos')
{
SlideOut(move);
$("#relativeContainer").css('z-index','-1');
alert('content is photos');
}
}