読み込み中の gif を表示し、ajax スクリプトの読み込みが完了したときに非表示にする方法をいくつか試しました。私は $j(window).load を試しましたが、現在、別の場所でロード中の gif div 要素に hide() 関数を配置しようとしています。関数内の他のスクリプトが読み込まれるまで、読み込み中の gif を表示する方法がわかりません。私に何ができるかわかりますか?(すべての $j('#loading'). hide() をコメントアウトすると、実際に読み込み中の gif が表示されます)。SimpleWithAttrPrices 関数は ajax スクリプトを実行し、値を返します。
function updatePrices(IDs){
var product_id= <?=$product_id ?>;
var qty= parseInt($j("#qtyUpdateBox input").val());
$j('#loading').show();
if (qty==1){
function sendRequest(i,basePrice) {
var optionSelectionArray = currentlySelectedAttributes(IDs[i]);
simpleWithAttrPrice(optionSelectionArray, function(data) {
//var vendor = IDs[i];
var basePrice = parseFloat(roundDollar(data));
$j('.details'+IDs[i]+ ' .priceBlock').empty();
$j('.details'+IDs[i]+ ' .priceBlock').append('<span>'+formatCurrency(basePrice,"$")+'</span>');
$j('.details'+IDs[i]+ ' .priceBlock').append('<input type="hidden" name="customPrice" value="' + basePrice + '"/>');
});
}//end sendRequest
for(i=0; i<IDs.length; i++)
{
sendRequest(i);
if(i=IDs.length-1){
$j('#loading').hide();
}
}
//$j('#loading').hide();
}//end if
//... THE REST OF THE FUNCTION NOT APPLICABLE