-1

私は、データが読み込まれるまで読み込まれた画像を表示するという概念の初心者です。データの読み込みに時間がかかりすぎるので、それまではローダーの画像を表示したい。この点で誰かが私を助けることができますか? ご参考までに、PHP ファイルと Smarty テンプレート ファイル (つまり HTML) のコードを以下に示します。以下は私のPHPコードです:

<?php 
  require_once("../../includes/application-header.php");

  $objQuestionMatch  = new QuestionMatch();

  $request = empty( $_GET ) ? $_POST : $_GET ;


  if($request['subject_id']!="") 
    $subject_id = $request['subject_id'];
  if($request['topic_id']!="") 
    $topic_id = $request['topic_id'];

  if($subject_id !='' && $topic_id !='')
    $all_match_questions = $objQuestionMatch->GetSimilarQuestionsBySubjectIdTopicId($subject_id, $topic_id);

  $smarty->assign('all_match_questions', $all_match_questions);
  $smarty->display("match-question.tpl")
?>

Smarty テンプレート コードは次のとおりです。

<form id="delete-questions-form" name="delete-questions-form" action="{$control_url}modules/questions/match_question.php" method="post">
<table width="100%" class="base-table tbl-practice" cellspacing="0" cellpadding="0" border="0">
  <tr class="evenRow">
    <th width="33%" style="text-align:center;" class="question-id">Que ID</th>
    <th width="33%" style="text-align:center;" class="question-id">Matching Que IDs</th>
    <th width="33%" style="text-align:center;" class="question-id">Percentage(%)</th>
  </tr>
{if $all_match_questions}
  {foreach from=$all_match_questions item=qstn key=key}   
    {if $qstn.similar_questions_ids_and_percentage}
      {assign var=counter value=1}
  <tr class="oddRow">
    <td class="question-id" align="center" valign="top">
      <a href="{$qstn.return_url}" title="View question" class="inline_view_question_detail">QUE{$qstn.question_id}</a>{if $qstn.question_appeared_count gt 0}-Appeared({$qstn.question_appeared_count}){/if}
    </td>
      {foreach from=$qstn.similar_questions_ids_and_percentage item=question key=q_no}
        {if $counter gt 1}
    <tr class="oddRow"><td class="question-id" align="center" valign="top"></td>
        {/if}
    <td class="question" align="center" valign="top">

        {if $question.question_id!=''}
      <a href="{$qstn.return_url}" title="View question" class="inline_view_question_detail">QUE{$question.question_id}</a>{if $question.question_appeared_count gt 0}-Appeared({$question.question_appeared_count}){/if}
        {if $question.question_appeared_count eq 0}
      <a id ="{$question.question_id}" href="#" class="c-icn c-remove delete_question"  title="Delete question"> Delete</a>{/if}
        {/if}

    </td>

    <td class="question" align="center" valign="top">
        {if $question.percentage!=''}{$question.percentage}{/if}
        {assign var=counter value=$counter+1}
    </td>
  </tr>
      {/foreach}               
    {/if}
  {/foreach}
{else}
  <tr>
    <td colspan="2" align="center"><b>No Questions Available</b></td>
  </tr>
{/if}
</table>
</form>
4

4 に答える 4

0

PHPはあなたのためにそれをするつもりはありません。jQuery/JS になります。このようなもの

$(‘#image-selector’).load(function(){
    //Do stuff after image is loaded
});
于 2013-12-11T10:46:43.113 に答える
0

このdivをページの上に追加してみてください

<div id="spinner_load" ></div>

このスクリプトをページに配置します

$(window).load(function() { $("#spinner_load").fadeOut("slow"); });

スタイル

#spinner_load
{
position: fixed;left: 0px;
top: 0px;
width: 100%;height:
 100%;
z-index: 9999;
background:#000 url(images/483.GIF) no-repeat;
background-position:center
}
于 2013-12-11T10:42:48.887 に答える
0

ID 読み込みで div を作成し、そこにスピナー アイコンまたはテキストを追加して、これを JS ファイルに追加します。

$( document ).ajaxStart(function() {
    $( "#loading" ).show();
});

$( document ).ajaxComplete(function( event,request, settings ) {
    $( "#loading" ).hide();
});
于 2013-12-11T10:41:24.610 に答える