製品の画像ギャラリーを作成しましたが、2 つの異なるビューがあります。ビューが選択されるたびに、ajax リクエストがサーバーに送信され、json オブジェクトが返されます。私のコードは現在動作していますが、高速化できるのではないかと心配しており、$.empty() がメモリから json オブジェクトを本当にクリアするかどうかはわかりません。
コード:
<div id=grid2></div>
<div id=grid4></div>
<section id=maindisplay>
$.ajax({ // DEFAULT VIEW
url: 'query.php',
data: "",
dataType: 'json',
success: ajaxfunction
});
function ajaxfunction(json_data){
console.log (json_data)
//format json_data here in to a table
$("#maindisplay").append(table);
}
$("#grid2").click(function(){
$.ajax({
url: 'query.php',
data: "",
dataType: 'json',
success: ajaxfunction2
});
});
function ajaxfunction2(json_data){ //ONE OF THE GRID VIEWS
$("#maindisplay").empty();
console.log (json_data)
//format json_data here in to a table
$("#maindisplay").append(table);
}
</section>
試してみましたが、json データを使用して別のオブジェクトをローカルで作成し、別の呼び出しを行わずに再利用できますか?